Using $.ajax or $.post to call MVC 5 Controller method

后端 未结 2 1356
抹茶落季
抹茶落季 2021-01-29 06:42

I\'m trying to set up what should be a very simple call from an MVC page to a controller using JavaScript. This is my Controller:

Imports System.Web.Mvc

Namespa         


        
2条回答
  •  逝去的感伤
    2021-01-29 06:47

    You need to set processData to true as you are sending an object which will need to be converted to a querystring.

    From the API:

    ProcessData
    By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.

    http://api.jquery.com/jQuery.ajax/

提交回复
热议问题