Home >Web Front-end >JS Tutorial >Jquery post passing array method implementation ideas and code_jquery

Jquery post passing array method implementation ideas and code_jquery

WBOY
WBOYOriginal
2016-05-16 17:34:56896browse

Take batch deletion of data as an example. To do batch deletion, you need to pass the data ID array to be deleted

Copy code The code is as follows:

function RemoveLog(){
var postModel=[];
//Traverse the checkbox to get the data ID to be deleted and store it in the array
$("[name='lid ']").each(function () {
if ($(this).attr("checked") == "checked")
postModel.push({ name: 'ids', value:$ (this).val()});
});
if(postModel.length == 0) {
alert('Please select the content to be deleted first!');
return ;
}
//post delete method, pass array
$.post('/admin/Delete',postModel,function(data){
});
}

Copy code The code is as follows:

//C# uses the corresponding List collection in the background The class can receive data
public JsonResult Delete(List ids)
{
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn