This is not a cross site request problem as most googled answers to my questions consists of.
I'm getting xhr.status 0 och xhr.statusText "error" when trying to make an ajax request with jquery functions .get and .load. In Firebug though, the requested page is loaded with html status code 200, I can read the text in the response and the response header looks ok.
My code:
function GetProjectTask(e) {
var loader = $('#' + e + 'tasks div.loader');
var content = $('#' + e + 'tasks div.content');
var img = $('#' + e + 'tasks img.collapseimg');
if (loader.html() == null || loader.html().trim() == '') {
if (content.html() == null || content.html() == '') {
img.attr('src', 'images/expanded.gif');
loader.html('<img src="images/loading.gif" alt="Wait..."> Loading support tasks');
content.load('includes/my' + e + 'tasks.php',
function (response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
alert(msg + xhr.status + " - " + xhr.statusText);
}
}
);
return;
}
}
content.empty();
loader.empty();
img.attr('src', 'images/collapsed.gif');
}
Server: IIS v.7.5 Jquery: v1.6.2
Any ideas?
Response status code 0, was caused (in my case while I was developing a website) by making xhr requests from page served by my local server to the same server on localhost.
Other reason (with possible solutions) can be found here:
"Make sure that you are using relative URLs for your AJAX requests." - invalid HTTP response code ‘0’