~~~
--------------------html部分---------------------------------
1
2
3
4
5
6
7
8
js
jquery
--------------------js部分------------------------------
//原生获取
function fun(){
obj = document.getElementsByName("ids");//input框name
check_val = [];
for(k in obj){
if(obj[k].checked)
check_val.push(obj[k].value);
}
//用JQ的ajax提交
$.ajax({
url: "{:url('blog/datadel')}",
data:{check_val},
type: 'post',
success: function (data) {
if (data.code == 1) {
layer.alert(data.msg, {icon: 6}, function (index) {
layer.close(index);
window.location.href = "{:url('index')}";//跳转
});
} else {
layer.alert(data.msg, {icon: 5}, function (index) {
layer.close(index);
})
}
}
})
}
//JQ获取
function jqueryFun(){
var ids = [];
$("input[name='ids']:checked").each(function(i){//ids是input框name
ids.push($(this).val());
});
//用JQ的ajax提交
$.ajax({
url: "{:url('blog/datadel')}",
data:{ids},
type: 'post',
success: function (data) {
if (data.code == 1) {
layer.alert(data.msg, {icon: 6}, function (index) {
layer.close(index);
window.location.href = "{:url('index')}";//跳转
});
} else {
layer.alert(data.msg, {icon: 5}, function (index) {
layer.close(index);
})
}
}
})
}
~~~