Pass array to ajax request in $.ajax()

后端 未结 2 1676
梦毁少年i
梦毁少年i 2021-01-22 14:48

I have tried like this but could not get array list. It returns \'null\'

 var data=[];
 data[0] = \'1\';
 data[1] = \'2\';
    $.ajax({                    
              


        
2条回答
  •  离开以前
    2021-01-22 15:25

    var datas = { data0: '1',
          data1: '2' };
    $.ajax({                    
             url: '@Url.Action("AddFrequencyWeekly", "Plannar")',
             type: "POST",                     
             data: datas,
             dataType: 'json', 
             success: function (data) {                                            
                 alert("Record Updated Successfully");    
                     }
             });
    

提交回复
热议问题