I am using Jquery autocomple with remote datasource, but, sometimes when try do search in my server a error is returned , because I’m using a rest webservice like datasource.
I’d like to know what returned status code by my webservice and print a error message
Example:
$(idObjeto).autocomplete({
source:url,
minLength: 3,
select:function(data,ui){
$(formatIdJQuery(idObjValueReceptor)).val(ui.item.id);
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + " - <strong>" + item.id + "</strong></a>" )
.appendTo( ul );
};
}
Suppose what my webservice returned status code 404, I’d like to get this status code and call alert window, for example.
That’s all folks!
You could re-structure your widget to use a function as the
sourceparameter, then make the AJAX request yourself and do whatever you’d like upon an error: