-1

What is wrong with the AJAX request? for some reason my browser picks it up as a GET request, when I specified it as a post???

 var body = "<tsRequest><credentials name='username' password='password'><site contentUrl=''/></credentials></tsRequest>";
var url = "http://172.18.74.145/api/2.0/auth/signin";

$.ajax({
    url: url,
    crossDomain: true,
    data: body, 
    type: 'POST',
    contentType: "text/xml",
    dataType: "jsonp",
    success : console.log("too"),
    error : function (xhr, ajaxOptions, thrownError){  
        console.log(xhr.status);          
        console.log(thrownError);
    } 
}); 

I get the error: GET http://172.18.74.145/api/2.0/auth/signin?callback=jQuery1720699254485778510…%20contentUrl=%27%27/%3E%3C/credentials%3E%3C/tsRequest%3E&_=1442263213074 405 (Method Not Allowed)

and if I change the "ajax" to "post" then the url is messed up.

Ben
  • 391
  • 1
  • 5
  • 19

1 Answers1

0

You need to specify the HTTP method as

type: 'POST',

and not as

method:'POST',

But anyway you basically can't use JSONP with POST.

Community
  • 1
  • 1
wero
  • 32,544
  • 3
  • 59
  • 84