I have gone through all the suggested links to find out the solution but still when I trying to make $.post()
it sending GET
as a Request_Method
and it is giving me error
我已经浏览了所有建议的链接以找出解决方案但仍然在我尝试生成$ .post()时它将GET作为Request_Method发送并且它给了我错误
GET https://example.com/samewebservice/save 405 (Method Not Allowed)
获取https://example.com/samewebservice/save 405(不允许使用方法)
It is a Cross Origin Request so I have enable all the CORS setting on server, If i execute $.get()
method it is giving me response in JSON format successfully.
这是一个Cross Origin Request,所以我在服务器上启用了所有CORS设置,如果我执行$ .get()方法,它会成功地给我JSON格式的响应。
But when m trying to execute $.post()
method it is giving me error.
但是当我试图执行$ .post()方法时,它给了我错误。
POST ajax request
POST ajax请求
function postAjax(URL,jsonData){
$.post(URL,jsonData,function(data){
response = data;
alert("In success");
console.log(data);
},"jsonp");
return response;
}
On browser header I am getting this
在浏览器标题上我得到了这个
3 个解决方案
#1
4
Just a guess. Try adding the type also
只是一个猜测。尝试添加类型
function postAjax(URL,jsonData){
$.post(URL,jsonData,
type:'POST',
function(data){
response = data;
alert("In success");
console.log(data);
},
"jsonp");
return response;
}
B/w the jsonp datatype might be the reason here. Check this answer
不包含jsonp数据类型可能就是这里的原因。检查这个答案
#2
0
You can't POST using JSONP...it creates a <script>
element to fetch data..which has to be a GET request.
你不能使用JSONP进行POST ...它创建一个
#3
0
I had a [FromBody] before my "HttpRequestMessage request" parameter; and this wasn't parsing correctly..........
我的“HttpRequestMessage请求”参数之前有一个[FromBody];这没有正确解析..........
#1
4
Just a guess. Try adding the type also
只是一个猜测。尝试添加类型
function postAjax(URL,jsonData){
$.post(URL,jsonData,
type:'POST',
function(data){
response = data;
alert("In success");
console.log(data);
},
"jsonp");
return response;
}
B/w the jsonp datatype might be the reason here. Check this answer
不包含jsonp数据类型可能就是这里的原因。检查这个答案
#2
0
You can't POST using JSONP...it creates a <script>
element to fetch data..which has to be a GET request.
你不能使用JSONP进行POST ...它创建一个
#3
0
I had a [FromBody] before my "HttpRequestMessage request" parameter; and this wasn't parsing correctly..........
我的“HttpRequestMessage请求”参数之前有一个[FromBody];这没有正确解析..........