简体   繁体   中英

jquery $.post() does not work in IE

I know that there a lot of such questions,but I do not find my answer.

Here is the code that works well in all browser. But IE ignore it.

HTML (One form for two submissions)

<form id="form0" method="post" accept-charset="UTF-8" 
 onsubmit="sendEmails(); return false;">
              <input id="ef" value="">
</form>

JS

function sendEmails() {

        var email = $('#ef').val();

        $('#FormValue_EmailAddress').val(email);
        $('#YMLPValue').val(email);

        $.ajaxSetup({ cache: false });          

        $.post($("#form1").attr("action"), $("#form1").serialize());
        $.post($("#form2").attr("action"), $("#form2").serialize());
}

Ok the issue was with IE security restrictions and adding json to POST. I was helped and my JS changed to this variant

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

        var request = $.ajax({
            type: "POST",
            url: $("#form1").attr("action"),
            data: $("#form1").serialize(),
            sync: false,
            dataType: 'jsonp',
            crossDomain: true        
        });

        request = $.ajax({
            type: "POST",
            url: $("#form2").attr("action"),
            data: $("#form2").serialize(),
            sync: false,
            dataType: 'jsonp',
            crossDomain: true
        });

Thanks for Daniel)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM