Question

My form sends perfectly well in Chrome and Firefox, with no errors displayed in firebug. However, in IE the form fails to send. I have narrowed it down to the $.post() function, which just doesnt seem to be called in IE. The callback function works, the call to the php file does not.

I have created a fiddle here - deleted to prevent spam - Enter your own email address in the supplied field. Submitting the form will send a confirmation email to you. This fiddle works in Chrome and Firefox, but not IE.

I have read questions with similar issues, but none solve mine.

In short, why does the $.post() function not work in IE?

The line in my .js:

var formData = $('#promo-form').serialize();
$.post('http://dynamic.lotterywest.wa.gov.au/promo-order/order.php', formData).always(formSent);
Was it helpful?

Solution

If you are using the always utility, the callback will trigger irrespective of whether your ajax request was success or error. See the docs.

Form your post request target, your ajax call appears to be a cross domain call. So check in the chrome-inspctor or firbug console for more info. $.ajax has crossdomain settings which will get you going on Firefox and chrome but it will still fail on IE browsers where XMLHttpRequest objects are not supported.

So just because the callback you given on the always part is triggered, you cannot confirm that the ajax request was success.

OTHER TIPS

Try like this

$('#promo-form').live("submit",(function(){
            forma = $(this);
            serial = $(forma).serialize();
...../
});

It will work or the issue was with IE security restrictions and adding json to POST.

$.support.cors = true; //  cross-site scripting
        $.ajaxSetup({ cache: false });          

        var request = $.ajax({
            type: "POST",
            url: $("#YOUR FORM").attr("action"),
            data: $("#YOUR FORM").serialize(),
            sync: false,
            dataType: 'jsonp',
            crossDomain: true        
        });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top