Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery AJAX request failing in IE

The following AJAX call is failing in IE.

$.ajax({     url:"{{SITE_URL}}/content/twitter.json",     dataType:"json",     error:function(xhr, status, errorThrown) {         alert(errorThrown+'\n'+status+'\n'+xhr.statusText);     },     success:function(json) {                ...Snip...     } }); 

The error function returns

Undefined parsererror OK 

No request is made to the server so I don't think its a problem with the JSON.

Fixed, See #1351389

like image 635
Sam Avatar asked Jan 08 '09 20:01

Sam


People also ask

What is a jQuery Ajax fail?

The jQuery ajax fail is an ajax event which is only called if the request fails. The AJAX fail is a global event that triggered on the document to call handler function, which may be listening. The ajax fail can be performed with the help of the ajaxError () function. The jQuery ajaxError () function is a built-in function in jQuery.

How to run function on Ajax request fail in JavaScript?

We can use the fail () callback function as well on the JavaScript promise object ( the jqXHR object return by the $.ajax () function) to run the specific function on the ajax request fail. $ (document).ajaxError (function (event, xhr, options, exc)); function (event, xhr, options) – This is not an optional parameter.

How do I stop ie from making Ajax calls?

Once IE has successfully made a GET request, it will no longer even make that AJAX call until the cache expires on that object. Fortunately, fixing the issue is easier than identifying it. There are several ways to prevent AJAX requests from being cached. One option is to simply use POST requests instead of GET requests in your application.

What happens if a jqxhr request fails?

But if the request is fails the fail () callback function used to call on the jqXHR object return by the ajax () function and display the notification message of the request as “.fail (function (jqXHR, textStatus, errorThrown) { alert (“The request generate error”); })”.


1 Answers

Fixed, I changed the content-type from application/json; charset=utf8 to just plain application/json.
I hate IE :)

Also to avoid IE super-caching try this:

var d = new Date(); $.ajax({         url:"{{SITE_URL}}/content/twitter.json?_="+d.getTime(),  ...Snip... 

That way each request is a new url for IE to get :D

like image 69
Sam Avatar answered Sep 19 '22 01:09

Sam