开发者

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, t开发者_JAVA技巧he 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?


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


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜