3

I have an ajax request working in FF, Chrome, Opera and Safari. I tested it in IE and it does the first of two request. It gets the IP from a php script, but then when it goes to post to my java servlet it doesn't send out the request; I tested with both fiddle and wireshark and the request isn't getting sent out. I've tried setting ajax cache to false didn't help. Not sure what it could be. The only difference in the php send out is IE does not send a Client Accept-Charset. This make me believe that the issue has to do with the first request; however it gets back data correctly so I'm kinda stumped ideas? I removed specific addresses, but the rest of the code is more or less the same.
Changed my code so that I do not have embedded request, I get it document ready, stops IE from freezing however it still does not send out. Also it now returns a generic error return on the Ajax Request. Change Code More Like Below

 <script>
$(function()
{
    function myfunction(event) 
    {  
        var email = $("#emailInput").val();
        if (email.indexOf('@') == -1 || email.indexOf('.') == -1)
        {
            alert("Please Enter a Valid Email");
        }
        else
        {   
            var eEmail = "email:" + email +"," + "ip:" + ip;
            Email = "="+encodeURIComponent(eEmail);

            $.support.cors = true;
            $.ajax(
                {
                url: 'myServletURI',
                type: 'POST',
                data: eEmail,
                cache: 'false',
                error: function(xhr,textStatus)
                {
                    alert(textStatus);
                },
                success: function(data)
                { 
                    //I have a JS lib I wrote to parse results
                    var result = makeDictionary(data);
                    if(result["command"] == "failed")
                    {
                        alert("Error");
                    }
                    else
                    {
                        window.location = "goToNextPage.html";
                    }                                                      
                }
            });
        }
    }
return false;
}); 
</script>

Thanks.

CubanAzcuy
  • 125
  • 1
  • 13
  • Have you fired up the IE developer tools "F12" and made sure there aren't any javascript errors in the console? You could also try step-by-step debugging and see if you get more information that way. – MichaC Jul 12 '12 at 00:34
  • Yes I did I got a little more data but it didn't help me, it made me assume it was cross-site error but I have it enable in my servlet as is shown by all other browsers getting the response, so still stuck. I got back the xhr element data `readyState 0 Number` `status 0 Number` `statusText "No Transport" String` – CubanAzcuy Jul 12 '12 at 03:37
  • I may have found a solution can't check at the moment will re post tomorrow. [link](http://stackoverflow.com/questions/9160123/no-transport-error-w-jquery-ajax-call-in-ie) – CubanAzcuy Jul 12 '12 at 03:56
  • I thought it could have been the $.support.cors = true; as it was an issue for other people so I changed it update code to reflect change. I get a new statusText returned. `statusText "Error: Access is denied.\r\n" String` – CubanAzcuy Jul 12 '12 at 14:48

2 Answers2

2

Your comment that you thought it might be a cross-site error makes me thing that maybe this holds your answer: Access denied to jQuery script on IE

The gist is that you can't use jquery to make cross site ajax requests in IE, you have to use XDomainRequest.

Community
  • 1
  • 1
MichaC
  • 2,834
  • 2
  • 20
  • 20
  • This was the issue. Solved it a bit before you posted this was just about to update. But yes and thank you. – CubanAzcuy Jul 14 '12 at 15:57
0

I use "GET" instead of "POST" and it's working for me in IE9

Ali Seyfollahi
  • 2,662
  • 2
  • 21
  • 29