XMLHttpRequest 无法加载 [url] 预检响应具有无效的 HTTP 状态代码 405
XMLHttpRequest cannot load [url] Response for preflight has invalid HTTP status code 405
这是我的 ajax 代码:
var param = "<ClientOrder xmlns='http://www.eysnap.com/mPlayer'>";
param += "<ClientId>CRF-1</ClientId>";
param += "<UserKey>598zxc8ddl45a3cvScuk</UserKey>" ;
param += "<PassKey>p1re254l3jd83os00cpk</PassKey>";
param += "<OrderId>123132323435</OrderId>";
param += "</ClientOrder>";
$.ajax({
url: URL,
data: param,
type: 'POST',
contentType: "text/xml",
dataType: "text",
success: function(result){
alert('success');
$("#div1").html(result);
},
error: function (xhr) {
alert('error');
$("#div1").html(xhr.responseText);
}
});
我呼叫的服务是 restful。疯狂的是,当我调用 GET 服务时,它 returns 数据正确,但是使用 POST 服务时它给出了这个错误:
XMLHttpRequest cannot load [url]. Response for preflight has invalid HTTP status code 405
如有任何帮助,我们将不胜感激。
原来是命名空间问题。
<ClientOrder xmlns='http://www.eysnap.com/mPlayer'>
我更改了命名空间以更正一个。
这是我的 ajax 代码:
var param = "<ClientOrder xmlns='http://www.eysnap.com/mPlayer'>";
param += "<ClientId>CRF-1</ClientId>";
param += "<UserKey>598zxc8ddl45a3cvScuk</UserKey>" ;
param += "<PassKey>p1re254l3jd83os00cpk</PassKey>";
param += "<OrderId>123132323435</OrderId>";
param += "</ClientOrder>";
$.ajax({
url: URL,
data: param,
type: 'POST',
contentType: "text/xml",
dataType: "text",
success: function(result){
alert('success');
$("#div1").html(result);
},
error: function (xhr) {
alert('error');
$("#div1").html(xhr.responseText);
}
});
我呼叫的服务是 restful。疯狂的是,当我调用 GET 服务时,它 returns 数据正确,但是使用 POST 服务时它给出了这个错误:
XMLHttpRequest cannot load [url]. Response for preflight has invalid HTTP status code 405
如有任何帮助,我们将不胜感激。
原来是命名空间问题。
<ClientOrder xmlns='http://www.eysnap.com/mPlayer'>
我更改了命名空间以更正一个。