I can't seem to get this solution to work for me.
How to catch error in jQuery's load() method
here's the code I'm trying.
$("#a").load("load.html", function(responseText, textStatus, XMLHttpRequest) {
if (textStatus == "error") { alert("fail"); }
else { alert("success"); }
});
when load.html exists, it works fine, but when it doesn't nothing happens. Which makes sense since it shouldn't get to the callback if it fails.
Can someone point out where I am going wrong? I'm trying to get it to throw out an error when the URL doesn't exist.
I'm trying to work with jQuery 1.3.2 if that affects anything.
Update The problem seems to be because I'm working locally and not on a server. Uploaded my files online and it seems to be working fine, is there parts of jQuery which require a server to function?
Update Did some more testing and using .load() with the error callback doesn't work offline, yet .ajax() does. Baffled at why, but there we go.