The array structure is: [ "5ae92c2786f3591b2cff1be5", "5ae91bb7ca673569a8d23a6e" ]
Front desk code:
$.ajax({ type: "POST", url: "/Registration/ManagementProject/DeleteProjectById", dataType: "json", data: {"selectData": that.UserIdArray }, async: false, traditional: true , // set to true here success: function (data) { that.projectList = data; console.log(data) if (data.Response.ErrCode == "0") { alert(data.Response.ErrMsg); // Clear the selected data that.UserIdArray = []; appList.GatProjectList( 1 ); } } });
Notice:
Notice:
1. that.UserIdArray is an array
2. The data in the ajax parameter is {"selectData": that.UserIdArray }
3. The most important thing in this way is traditional: true. Or convert the _list parameter to $.param(_list.true). Here is actually passing _list to the background as a traditional way, jQuery does the conversion by default
code behind
// / <summary> // / Delete items according to the selected ID // / </summary> // / <param name="selectData">The selected item array can also be List<string></param> // / <returns></returns> public IActionResult DeleteProjectById(string [] selectData) { }