There is an undefined error due to Ajax request in jQuery. But it works locally. Error referencing in jquery1.3.2.js @ 3633 line
xhr.send(s.data);
My code is:
$.ajax({
type: "POST",
url: 'index.php',
data: "action=showpath&type=images&path=&default=1",
cache: false,
dataType: "html",
success: function (data) {
$('#addr').html(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
alerts in code shows me (0, 'undefined');
What I am doing wrong?
The XMLHttpRequest object can be used to exchange data with a web server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.
The jqXHR Object. The jQuery XMLHttpRequest (jqXHR) object returned by $.ajax() as of jQuery 1.5 is a superset of the browser's native XMLHttpRequest object. For example, it contains responseText and responseXML properties, as well as a getResponseHeader() method.
onreadystatechange: It also defines a callback function that will be invoked when the readyState property changes. readyState: The readyState property defines the current state of the request or holds the current status of the XMLHttpRequest.
This could be happening if your ajax request is getting canceled before it completes. jQuery throws the error event when the user navigates away from the page either by refreshing, clicking a link, or changing the URL in the browser. You can detect these types of errors by by implementing an error handler for the ajax call, and inspecting the xmlHttpRequest object:
$.ajax({
/* ajax options omitted */
error: function (xmlHttpRequest, textStatus, errorThrown) {
if(xmlHttpRequest.readyState == 0 || xmlHttpRequest.status == 0)
return; // it's not really an error
else
// Do normal error handling
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With