jQuery Ajax 404 Handling

What you can also do is use the $.ajaxError function, like so

$("#message").ajaxError(function (event, request, settings) {
    $(this).show();
    $(this).append("<li>Error requesting page " + settings.url + "</li>");
});

Cross Site requests, JSONP, wont trigger the error calls. Just had the same problem myself: http://forum.jquery.com/topic/jquery-ajax-with-datatype-jsonp-will-not-use-error-callback-if-request-fails


I had a very similar result/problem. The bottom line is that I failed to make sure that my URL did not contain any of the same param names in the data section of the ajax function.


The reason for me, was that I generated the URL with php code to get a url

pines_url('com_referral', 'sendhttprequest')

which outputs to a url with a parameter

option=com_referral

and a parameter

action=sendhttprequest

My BIG problem was that I was also trying to send a param "action" in the data section of an AJAX function.

data: {"action": "getpoints"}

So the second action was overriding it "getpoints" does not exist, but the tricky part is that firebug would obviously not tell me the url with getpoints, it would tell me the url as sendhttprequest.

Hope that wasn't confusing, but I also hope this helps someone else with a similar problem!

Tags:

Jquery