o2o/admin/ category
view
view -> js
var SCOPE = {
'listorder_url': "{:url('category/listorder')}" ,
}
public/admin/conmon/common.js
/*更新排序ajax*/
$('.listorder input').blur(function () {
//编写抛送逻辑
//获取主键id
var id = $(this).attr('attr-id');
//获取排序的值
var listorder = $(this).val();
//获取的值组合成抛送的数组
var postDate = {
'id' : id,
'listorder' : listorder,
};
//获取url
var url = SCOPE.listorder_url;
//抛送http
$.post(url,postDate,function (res) {
if (res.code == 1){
setTimeout(function () {
location.href=res.data;
},500)
}
else{
layer.alert(res.msg,{icon:2});
}
},"json");
});
controller
public function listorder($id,$listorder)
{
$res = $this->obj->save(['listorder'=>$listorder],['id'=>$id]);
if ($res){
$this->result($_SERVER['HTTP_REFERER'],1,'success');
}
else{
$this->result($_SERVER['HTTP_REFERER'],0,'更新失败');
}
}