views:

82

answers:

4

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?

A: 

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.

meder
Okay, my appologies to IE. Just got Firefox 3.6 on my Mac to do the same thing. I was trying to get the response text in JSON format (via firebug) when it's now stuck in a mode that I have with IE. Every time I submit the page, ajax only returns data -1. Chrome (Mac) is correctly receiving the Json object, but now Firefox is stuck. Two browsers, talking to the same host - same wordpress app. Same data submit. I've flushed the cache. One works, the other doesn't. What conditions cause response text to be -1? I'll start digging but this is very weird.
Scott
A: 

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

Iscariot
The whole function:function ajaxLogin() { $ = $j; var params = { action : 'tsll_field_request', tsll_action : 'login', email: $('#email').val() }; $.post(ajaxurl,params,ajaxLoginCallback,"json"); return false; // don't send the form, we let the ajax handle it! }I'm starting to think the problem is on the server.
Scott
A: 
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

Elizabeth Buckwalter
+1  A: 

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

Scott