tp批量删除
利用ajax post操作
1、html
<th style="width:5px;"><input type="checkbox" class="checkall" /></th> <th style="width:5px;">编号</th>
<td align="center"><input type="checkbox" name="id[]" class="ids" value="{$row.id}" /></td>
<td align="center">{$row.id}</td>
2js代码做一个选择器
$(".checkall").click(function(){
$(".ids").prop("checked",this.checked);
});
$(".ids").click(function(){
$(".checkall").prop("checked",$(".ids:not(:checked)").size() == 0);
});
3、
$(".ajax-post").click(function(){
var form = $(this).closest("form");
var formdata = form.length?form.serialize():$(".ids").serialize();
console.debug(formdata);
var url = form.length?form.attr("action"):$(this).attr("url");
console.debug(url);
$.post(url,formdata,function(data){
updatealert(data);
});
return false;
});注:需要注意的是此时传到后台的id是一个数组,需要修改id的接收方式:$this->data["id"] = array("in",$id);声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: tp基本的增删改查的操作demo
- 下一篇:没有了
