ajax call, controller, class, match result, return array inputs(example to return)

This commit is contained in:
marcos 2019-12-03 15:11:16 +01:00
parent 631170bfe9
commit 14b8379ccb
2 changed files with 22 additions and 6 deletions

View File

@ -642,6 +642,22 @@ if ($config['menu_type'] == 'classic') {
if( $('#keywords').val() === ''){
$('#result_order').hide();
}else {
$.ajax({
type: "POST",
url: "ajax.php",
dataType: "text",
data: {
page: 'include/ajax/order_interpreter',
method: 'getResult',
text: $('#keywords').val(),
},
success: function (data) {
console.log(data);
},
error: function (data) {
console.error("Fatal error in AJAX call to interpreter order", data)
}
});
$('#result_order').show();
}
}

View File

@ -117,20 +117,20 @@ class OrderInterpreter extends Wizard
/**
* Method to print order interpreted on header search input.
*
* @return void
* @return array
*/
public function getResult()
public function getResult():array
{
// Take value from input search.
$text = get_parameter('text', '');
$array_found = [];
foreach ($this->pages_name as $key => $value) {
if (preg_match('/'.$text.'/', $value)) {
echo 'pene gordo';
if (preg_match('/.*'.$text.'.*/', $value)) {
$array_found[$key] = '<input id='.$key.'><a href="'.$this->pages_url[$key].'">'.$value.'</a>';
}
}
return;
return $array_found;
}