Search code examples
internet-explorerjqueryjquery-post

Jquery Ajax Request Not Being Sent In IE


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.


Solution

  • 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.