diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index 0510299fbd7..15541016963 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -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);