Scott
Scott

Reputation: 41

JQuery.ajax works on every platform except IE

I have a simple ajax call that works correctly on EVERY other platform except IE. It work on my mac, Ubuntu, Windows Chrome, Windows Firefox, but NOT IE

var params = "action=tsll_field_request&tsll_action=login&email=foo";
$.ajax({
  type: "POST",
  url: ajaxurl,
  data: params,
  dataType: "json",
  error: function(xhr, status, errorThrown) {
    alert(errorThrown + '\n' + status + '\n' + xhr.statusText);
  },
  success: ajaxLoginCallback
});

the error function is never called, the ajaxLoginCallback status is always success BUT data (the parameter passed to ajaxLoginCallback) is always -1 on IE. the data returned is a json item formatted with php's json_encode().

I am at a complete loss as to why THIS browser is not parsing the JSON and why I don't get an error.

Can anyone give me a clue?

Upvotes: 2

Views: 524

Answers (4)

Elizabeth Buckwalter
Elizabeth Buckwalter

Reputation: 968

if ($snarky) { print "A lot of stuff works on every platform except for IE." }  

IE seems to cache responses despite requesting it not to. A potential answer from JQuery Google Group

Upvotes: 0

Scott
Scott

Reputation: 41

I think I finally figured it out.

If I'm not LOGGED INTO Wordpress, my ajax call is being "rejected". There's no error, but the call isn't being passed through to my plugin.

During development, I usually open two tabs, one on the administrative side (wp-admin) and one on the public site IN the same browser. IE is the last browser I check so I never open the admin tab. If I'm not logged in to wordpress, the call to: mydomain.org/wp-admin/admin-ajax.php must be returning a -1.

So the Ajax call goes out, it's successful (hence no error), but I don't have the necessary approvals to execute it so I get a -1 in response.

Doh... Feeling foolish but I hope this helps someone else. – Scott

Upvotes: 2

meder omuraliev
meder omuraliev

Reputation: 186562

Can you post the JSON data? Maybe it's malformed? ( Trailing commas and what not ). Try making a JS file using that JSON data and try querying it.

Upvotes: 0

Case
Case

Reputation: 4272

Nothing looks wrong on a syntax level, but what other variables are you using, perhaps something is wrong there.

Upvotes: 0

Related Questions