【发布时间】:2023-03-05 18:33:01
【问题描述】:
我正在尝试从 localhost 运行此脚本,但收到错误 405 (Method Not Allowed)。
代码
$(document).ready(function(){
$.ajax({
url:'http://some.url/',
type:'post',
//crossDomain: true,
data:'{id:"49"}',
contentType: "application/json; charset=utf-8",
dataType:'jsonp',
success: function(responseData, textStatus, jqXHR) {
alert('right');
var value = responseData.someKey;
console.log(value);
},
error:function() {
alert("Sorry, I can't get the feed");
}
});
});
我尝试了crossDomain:true 和$.support.cors = true,但没有用。有什么想法吗?
【问题讨论】:
-
实际服务器是否返回正确的 CORS 标头?设置这些属性只会使其检查这些标题。
-
@Qantas94Heavy 我无法访问服务器代码。如何检查?
-
@Rohan Kumar 谢谢。现在更新了网址。我之前放了一个虚拟网址。
标签: javascript jquery ajax cross-domain