Asp.net Mvc Ajax Json (post Array)

前端 未结 2 840
南方客
南方客 2021-01-14 01:21

javascript\\jQuery:

 var items = new Array();

 var obj { Begin: \"444\", End: \"end\" };

 items.push(obj);
 items.push(obj);

  var request = {
                    


        
相关标签:
2条回答
  • 2021-01-14 01:27

    Try write code as below:

    var option = {
      url: '/Home/Index',
      type: 'POST',
      data: JSON.stringify(request),
      dataType: 'html',
      contentType: 'application/json',
      success: function(result) {
        alert(result);
      }
    };
    $.ajax(option);
    
    0 讨论(0)
  • 2021-01-14 01:50

    U can't pass mass: items and expect it to be serialized as a JSON array automatically, you will need to either iterate and construct the JSON (bad plan) or use a JSON library(good plan)

    0 讨论(0)
提交回复
热议问题