Javascript Ajax 405(不允许使用方法)跨域问题
我试图从localhost运行此脚本,但它得到一个错误405(不允许使用方法) 代码Javascript Ajax 405(不允许使用方法)跨域问题,javascript,jquery,ajax,cross-domain,Javascript,Jquery,Ajax,Cross Domain,我试图从localhost运行此脚本,但它得到一个错误405(不允许使用方法) 代码 $(document).ready(function(){ $.ajax({ url:'http://some.url/', type:'post', //crossDomain: true, data:'{id:"49"}', contentType: "application/json; charset=utf-8",
$(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无关,HTTP 405表示不允许使用HTTP方法,例如GET、POST等
根据Chrome开发工具,HTTP方法只允许POST和选项
要使用发送POST请求,请使用以下命令:
$.ajax('url', {
// other settings here
type: 'POST'
}
您也可以使用包装器方法来做同样的事情
请注意,所讨论的特定站点尚未设置跨源支持,因此,如果您需要访问此站点,则需要让该站点解决此问题,或者需要将服务器用作代理。实际服务器是否返回正确的CORS头?设置这些属性只会检查这些标题。因为不是responding@Qantas94Heavy我无法访问服务器代码。如何检查?@Rohan Kumar谢谢。现在更新了url。我之前已经放置了一个虚拟url。谢谢回复。请求的反向代理是什么??