javascript - Ajax jqXHR.status==0 fix error -
$.ajax({ url: urlstring, datatype: "json", type: "get", success: function (data) { alert(data); }, error: function (jqxhr, exception) { if (jqxhr.status === 0) { alert('not connect.\n verify network.'); } else if (jqxhr.status == 404) { alert('requested page not found. [404]'); } else if (jqxhr.status == 500) { alert('internal server error [500].'); } else if (exception === 'parsererror') { alert('requested json parse failed.'); } else if (exception === 'timeout') { alert('time out error.'); } else if (exception === 'abort') { alert('ajax request aborted.'); } else { alert('uncaught error.\n' + jqxhr.responsetext); } } });
this javascript file im using access information server. urlstring supplied , correct. did download .json server retrieving , accessed locally on computer. when go access file server keep getting jqxhr.status==0 error. i'm not sure how fix because can't see wrong code.
can point me in right direction fix error?
the reason different status codes file isn't fetched http:
protocol file:
protocol. it's natural different protocols have different status codes.
you need have different behaviour depending on fetch file from.
there mozilla bug report this, marked invalid because considered correct result.
Comments
Post a Comment