Skip to content
Snippets Groups Projects
Commit cd086906 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix ajax search product that return bad json response

parent 8f7371cd
No related branches found
No related tags found
No related merge requests found
......@@ -160,7 +160,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id))
}
echo json_encode($outjson);
}
}
else
{
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php';
......@@ -171,17 +171,23 @@ else
top_httphead();
if (empty($htmlname))
return;
{
print json_encode(array());
return;
}
$match = preg_grep('/(' . $htmlname . '[0-9]+)/', array_keys($_GET));
sort($match);
$idprod = (! empty($match[0]) ? $match[0] : '');
if (! GETPOST($htmlname) && ! GETPOST($idprod))
return;
// When used from jQuery, the search term is added as GET param "term".
if (GETPOST($htmlname) == '' && ! GETPOST($idprod))
{
print json_encode(array());
return;
}
// When used from jQuery, the search term is added as GET param "term".
$searchkey = (GETPOST($idprod) ? GETPOST($idprod) : (GETPOST($htmlname) ? GETPOST($htmlname) : ''));
$form = new Form($db);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment