?Briella 2016-06-04 11:56 采纳率: 0%
浏览 66

httpPost没有运行方法

I have a problem with MVC application, the browser is not able to send POST data to the controller method. I did a test with the parameter "GET" - parameter is passed. "POST" - nothing happens is NOK. What to do to POST work?

var save = function()
{
   var data = document.getElementById('tarea').innerHTML;
   data = JSON.stringify("PiotrDusiskissssssssssssss");
   // da = JSON.stringify(da);
    //debugger;
   console.log(data);
   $.ajax({
       type: 'POST',
       timeout: 3000, // sets timeout to 3 seconds
       url: 'http://localhost:62658/Home/SaveEntry',
       dataType: "json",
       data: {'data':"sdfsdfsdfsdfsd"},
       contentType: "application/json;charset=utf-8",
       success: function (result) {
           console.log('success');
           alert("We returned:" + result);
       },
       failure: function (e) {
           console.log('problem');
           alert(e);
       }
   });      
};

Problem: method is not fired when I use [HttpPost] method is run for [HttpGet]

[HttpPost]
[ValidateInput(false)]
public JsonResult SaveEntry(string data)
{   
    string wynik;
    string sqlQuery =...
  • 写回答

1条回答 默认 最新

  • weixin_33713350 2016-06-04 13:54
    关注

    You specified type:'POST' it should be

    $.ajax({
        method:'POST',
        //...
    })
    
    评论

报告相同问题?