Post an object as data using Jquery Ajax

后端 未结 6 2086
栀梦
栀梦 2020-11-28 10:24

My code that I tried is as follows:

var dataO = new Object();
dataO.numberId = 1;
dataO.companyId = 531;

$.ajax({
 type: \"POST\",
 url: \"TelephoneNumbers.         


        
6条回答
  •  星月不相逢
    2020-11-28 10:56

    Is not necessary to pass the data as JSON string, you can pass the object directly, without defining contentType or dataType, like this:

    $.ajax({
        type: "POST",
        url: "TelephoneNumbers.aspx/DeleteNumber",
        data: data0,
    
        success: function(data)
        {
            alert('Done');
        }
    });
    

提交回复
热议问题