Better error management
This commit is contained in:
parent
154d1520fb
commit
6e54577167
@ -98,26 +98,30 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
$("input#search_'.$htmlname.'").autocomplete({
|
||||
source: function( request, response ) {
|
||||
$.get("'.$url.($urloption?'?'.$urloption:'').'", { '.$htmlname.': request.term }, function(data){
|
||||
response($.map( data, function( item ) {
|
||||
if (autoselect == 1 && data.length == 1) {
|
||||
$("#search_'.$htmlname.'").val(item.value);
|
||||
$("#'.$htmlname.'").val(item.key).trigger("change");
|
||||
}
|
||||
var label = item.label.toString();
|
||||
var update = {};
|
||||
if (options.update) {
|
||||
$.each(options.update, function(key, value) {
|
||||
update[key] = item[value];
|
||||
});
|
||||
}
|
||||
var textarea = {};
|
||||
if (options.update_textarea) {
|
||||
$.each(options.update_textarea, function(key, value) {
|
||||
textarea[key] = item[value];
|
||||
});
|
||||
}
|
||||
return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled }
|
||||
}));
|
||||
if (data != null)
|
||||
{
|
||||
response($.map( data, function(item) {
|
||||
if (autoselect == 1 && data.length == 1) {
|
||||
$("#search_'.$htmlname.'").val(item.value);
|
||||
$("#'.$htmlname.'").val(item.key).trigger("change");
|
||||
}
|
||||
var label = item.label.toString();
|
||||
var update = {};
|
||||
if (options.update) {
|
||||
$.each(options.update, function(key, value) {
|
||||
update[key] = item[value];
|
||||
});
|
||||
}
|
||||
var textarea = {};
|
||||
if (options.update_textarea) {
|
||||
$.each(options.update_textarea, function(key, value) {
|
||||
textarea[key] = item[value];
|
||||
});
|
||||
}
|
||||
return { label: label, value: item.value, id: item.key, update: update, textarea: textarea, disabled: item.disabled }
|
||||
}));
|
||||
}
|
||||
else console.error("Error: Ajax url '.$url.($urloption?'?'.$urloption:'').' has returned an empty page. Should be an empty json array.");
|
||||
}, "json");
|
||||
},
|
||||
dataType: "json",
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/product/ajax/products.php
|
||||
* \file htdocs/product/ajax/company.php
|
||||
* \brief File to return Ajax response on product list request
|
||||
*/
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user