SweetAlert 使用

 1    $(".delete").click(function(){
 2 
 3             var work_name = $(this).data('name');
 4             var item_id = $(this).data('id');
 5            
 6 
 7             swal({
 8                 title: "确定删除该申请吗?",
 9                 type: "warning",
10                 showCancelButton: true,
11                 confirmButtonColor: "#2baab1",
12                 confirmButtonText: "确定",
13                 cancelButtonText:"取消",
14                 closeOnConfirm: false }
15             ).then(function(isConfirm) {
16 
17                 if (isConfirm === true) {
18 
19                     //ajax 请求
20                     $.get(
21 
22                         "/office/personner-apply/delete",
23                         {
24                             item_id:item_id,
25                             work_name:work_name
26                         },
27                         function(data){
28 
29                             if(data.code == 200)
30                             {
31                                 swal({ text:'删除成功',showConfirmButton: false,type: "success",timer:1000}).then(function(){
32 
33                                     window.location.reload();
34                                 });
35 
36                             }else{
37 
38                                 swal({ text:'删除失败',showConfirmButton: false,type: "error",timer:1000});
39                             }
40 
41                         },
42                         "json"
43                     );
44                 }
45             });
46         });

 

posted @ 2016-10-26 10:40  哦先生  阅读(1296)  评论(0编辑  收藏  举报