ajax 基本操作(批量操作)

//批量删除购物车中的商品
function deleteProductList(){
var checkboxs=document.getElementsByName("checkbox");
var ids='';
for(var i=0; i if(checkboxs[i].checked){
ids+=checkboxs[i].value + ',';

}
}
if(ids.length==0){
alert("至少选择一条!");
}else{
var deleteMessage={
"ids":ids
};
$.ajax({
url:ctxInterface+"/api/buycar/deleteBuyCar.json",// url
type:"post",
data:JSON.stringify(deleteMessage),
contentType : 'application/json',
dataType:"json",
beforeSend: function (xhr) {
xhr.setRequestHeader("Authentication-Token",getCookie("token")); //需要token
},
success:function(data){
if(data.code==200){
alert(data.msg);
location.reload();
}
return false;
},
error:function(){
return false;
}
});
}
}

    推荐阅读