jquery Ajax call - data parameters are not being passed to MVC Controller action

后端 未结 5 1464
粉色の甜心
粉色の甜心 2020-12-08 02:31

I\'m passing two string parameters from a jQuery ajax call to an MVC controller method, expecting a json response back. I can see that the parameters are populated on the cl

5条回答
  •  抹茶落季
    2020-12-08 03:21

      var json = {"ListID" : "1", "ItemName":"test"};
        $.ajax({
                url: url,
                type: 'POST',        
                data: username, 
                cache:false,
                beforeSend: function(xhr) {  
                    xhr.setRequestHeader("Accept", "application/json");  
                    xhr.setRequestHeader("Content-Type", "application/json");  
                },       
                success:function(response){
                 console.log("Success")
                },
                  error : function(xhr, status, error) {
                console.log("error")
                }
    );
    

提交回复
热议问题