modified 新增ajax put请求

This commit is contained in:
zhaoxiang 2016-11-11 00:26:37 +08:00
parent b41e37f48d
commit 32f5c17ffc
2 changed files with 50 additions and 4 deletions

View File

@ -64,19 +64,19 @@ class User extends Base {
[
'info' => '启用',
'href' => url('User/open'),
'class'=> 'btn-success',
'class'=> 'btn-success ajax-put-url',
'param'=> [$this->primaryKey],
'icon' => 'fa fa-check',
'confirm' => 0,
'confirm' => 1,
'show' => ['status', 0]
],
[
'info' => '禁用',
'href' => url('User/close'),
'class'=> 'btn-warning',
'class'=> 'btn-warning ajax-put-url',
'param'=> [$this->primaryKey],
'icon' => 'fa fa-close',
'confirm' => 0,
'confirm' => 1,
'show' => ['status', 1]
],
[

View File

@ -220,6 +220,52 @@
return false;
});
/**
* Ajax put by url 请求() *
*/
bodyDom.on('click', '.ajax-put-url', function() {
var url = $(this).attr('url'), urlData = '';
if( $(this).attr('data') ){
urlData = $(this).attr('data');
}
if( $(this).hasClass('confirm') ){
bootbox.confirm({
title: "温馨提醒:",
message: "您确定要这么做么?",
buttons: {
cancel: {
label: '<i class="fa fa-times"></i> 取消'
},
confirm: {
label: '<i class="fa fa-check"></i> 确定'
}
},
callback: function (result) {
if( result ){
$.ajax({
type: "PUT",
url: url,
data: urlData
}).done(function( data ) {
var wait = 1000*data.wait;
if (data.code == 1) {
$.alertMsg(data.msg);
setTimeout(function() {
if (data.url) {
$.refresh(data.url);
}
}, wait);
} else {
$.alertMsg(data.msg);
}
});
}
}
});
}
return false;
});
/**
* Ajax 刷新页面 *
*/