0

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?

Caleb
  • 21
  • 4

1 Answers1

0

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, i.e. 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.

Marko Gresak
  • 7,950
  • 5
  • 40
  • 46
  • I know the server can allow post requests because I can do a $.post and that works fine in chrome and firefox. The problem is ie8 and 9 cannot support a $.post cross domain so I have to do this ajax call . The request header I get back in chrome is: POST /dpc/cd/api/svcs/setpassword?format=json HTTP/1.1 – Caleb Jun 13 '15 at 22:40
  • Oh, I did not know old IEs don't support it. But sadly, if the `$.post` won't work, even `$.ajax` won't, since the first is just a syntactic sugar for `$.ajax` call. Have you checked [this question](http://stackoverflow.com/questions/6845150/jquery-post-ie8)? Also what version of jQuery are you using? – Marko Gresak Jun 13 '15 at 22:47
  • Well I am using a script that is actually making an xdr request the script is jQuery.XDomainRequest.js Using this script actually allows me to make get calls successfully it is just post calls that are not working – Caleb Jun 13 '15 at 23:41