简体   繁体   中英

Trying to make a Cross domain post call in IE9

I am trying to make a cross domain post call in IE9 below is my code:

$.support.cors = true;
var data = {"userid":uid,"email":email,"password":password};
if (isIE () && isIE () <= 9) {
    $.ajax({
        type: 'post',
        crossDomain: true,
        url: postUrl,
        cache:false,
        contentType: 'application/json; charset=utf-8',
        dataType: 'jsonp',
        data:data,
        jsoncallback:'localJsonpCallback',
        jsonp:false,
        success: function (data) {
            console.log(data);
        },
        error: function (status){
            console.log(status);
            $("#error").html("Incorrect E-mail Entered. Please Re-Enter Your E-mail "); 

        }
    });
}

function localJsonpCallback(json) {
    if (!json.Error) {
        alert("success");
    }
    else {

        alert(json.Message);
    }
}

However, When I look at the call in fiddler I am getting a 405 error and the request header is showing a GET:

GET postUrl?format=json&userid=123456&email=test%40test.com&password=Password1&_=1434232587917 HTTP/1.1

Why is it if I am making a post that in the request header it is showing a Get? Am I doing anything syntactically wrong with my call?

Your request looks okay and from the server response you're describing, it's a "problem" with server, HTTP status code 405 means bad method, ie server doesn't allow POST requests. But it's still strange that it would translate those to GET , but I still think it's because of server implementation, not an error on your side. You could try with a tool like curl and see what response headers you get, but it won't help much if it's an server bug/error.

If you do not have control over the server, the only things remaining is to contact the owner and ask them to allow post request or send a GET request, although it's really bad to send non-encoded login data.

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