The array structure is: ["5ae92c2786f3591b2cff1be5", "5ae91bb7ca673569a8d23a6e"]
Front Code:
$.ajax ({type:"POST", URL:"/registration/managementproject/deleteprojectbyid", DataType:"JSON", data: {"Selectdata": that. Useridarray}, Async:false, Traditional:true,//set to True hereSuccessfunction(data) {that.projectlist=data; Console.log (data)if(Data. Response.errcode = = "0") {alert (data. RESPONSE.ERRMSG); //Empty the selected datathat. Useridarray = []; Applist.gatprojectlist (1); } } });
Attention:
Attention:
1, that. Useridarray is an array
2. The data in the Ajax parameter is {"Selectdata": that. Useridarray}
3, this way is more important is traditional:true. or convert the _list parameter to $.param (_list.true). Here is actually the _list as a traditional way to pass to the background, jquery is the default is to do the conversion
Background code
// /<summary> // /Delete Items based on selected ID // /</summary> // /<param name= "Selectdata" > selected array of items can also be list<string></param> // /<returns></returns> Public Iactionresult Deleteprojectbyid (string [] selectdata) {
Ajax passes an array to the background. NET MVC Controller