Ajax 405(不允许的方法)跨域问题

我试图从localhost运行此脚本,但它得到错误405(方法不允许)

$(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开发工具,只有POST和OPTIONS是允许的HTTP方法。

Chrome开发工具响应标头

要使用jQuery.ajax()发送POST请求,请使用以下命令:

 $.ajax('url', { // other settings here type: 'POST' } 

您还可以使用jQuery.post()包装器方法执行相同的操作。

请注意,有问题的特定网站尚未设置跨域支持,因此,如果您需要访问此网站,则需要让网站解决此问题,或者您需要将服务器用作代理。