【发布时间】:2015-09-14 20:38:11
【问题描述】:
AJAX 请求有什么问题?出于某种原因,当我将其指定为帖子时,我的浏览器将其作为 GET 请求接收???
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);
}
});
我得到错误: 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(不允许的方法)
如果我将“ajax”更改为“post”,那么 url 就会混乱。
【问题讨论】:
标签: javascript ajax xml