Fix ajax search product that return bad json response
This commit is contained in:
parent
8f7371cdf0
commit
cd08690646
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user