javascript - JQuery $.ajax(),$.post() sending GET as Request Method - Stack Overflow

I have gone through all the suggested links to find out the solution but still when I trying to make $.

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

GET 405 (Method Not Allowed)

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.

But when m trying to execute $.post() method it is giving me error.

POST ajax request

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

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

GET https://example./samewebservice/save 405 (Method Not Allowed)

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.

But when m trying to execute $.post() method it is giving me error.

POST ajax request

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

Share Improve this question edited Jun 22, 2015 at 11:50 rachana asked Jun 22, 2015 at 10:52 rachanarachana 3,4347 gold badges31 silver badges50 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

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

You can't POST using JSONP...it creates a <script> element to fetch data..which has to be a GET request.

I had a [FromBody] before my "HttpRequestMessage request" parameter; and this wasn't parsing correctly..........

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745111890a4611898.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信