How to use getJSON, sending data with post method?

后端 未结 7 1009
暗喜
暗喜 2020-11-29 17:45

I am using above method & it works well with one parameter in URL.

e.g. Students/getstud/1 where controller/action/parameter format is applied.

7条回答
  •  执笔经年
    2020-11-29 18:32

    I had code that was doing getJSON. I simply replaced it with post. To my surprise, it worked

       $.post("@Url.Action("Command")", { id: id, xml: xml })
          .done(function (response) {
               // stuff
            })
            .fail(function (jqxhr, textStatus, error) {
               // stuff
            });
    
    
    
        [HttpPost]
        public JsonResult Command(int id, string xml)
        {
              // stuff
        } 
    

提交回复
热议问题