AJAX.JQ一些基本用法
2018-03-19 11:39
483 查看
1.ajax 的运用 --------------------(1)点击按钮
(2)js部分 function deleteuser(obj,id){ var token = "{{csrf_token()}}"; layer.confirm('确认要删除吗?',function(index){ $.ajax({ type: 'POST', url: '/admin/qiye/del', data:{id:id,_token:token}, dataType: 'json', success: function(data){ if(data.status == 200) { $(obj).parents("tr").remove(); layer.msg('已删除!', {icon: 1, time: 1000}); } else { layer.msg('删除失败!', {icon: 1, time: 1000}); } }, error:function(data) { console.log(data.msg); }, }); }); }
(3)返回部分(控制器里面)// 删除 public function del(Request $request){ $id = $request->input('id'); $res = QiyeModel::where('id',$id)->first(); if($res){ QiyeModel::where('id',$id)->delete(); return response()->json(['status'=>200,'msg'=>'删除成功']); }else{ return response()->json(['status'=>500,'msg'=>'删除失败']); } }
2.ajax获取表单参数——————————————————
获取表单里面的所有参数$('#form_edit').serialize()
获取单个参数$('#id').val();
ID为foem_edit tr为第五个 td为第四个 这条数据选中为true('#form_edit tr:nth-child(5) td:nth-child(4)').find('input').attr('checked','true');
跳转链接window.location.href="链接地址"
弹框 如果确定 继续执行confirm('确定要删除所选内容?');
重新加载该页面window.location.reload();
打印内容console.log();
(2)js部分 function deleteuser(obj,id){ var token = "{{csrf_token()}}"; layer.confirm('确认要删除吗?',function(index){ $.ajax({ type: 'POST', url: '/admin/qiye/del', data:{id:id,_token:token}, dataType: 'json', success: function(data){ if(data.status == 200) { $(obj).parents("tr").remove(); layer.msg('已删除!', {icon: 1, time: 1000}); } else { layer.msg('删除失败!', {icon: 1, time: 1000}); } }, error:function(data) { console.log(data.msg); }, }); }); }
(3)返回部分(控制器里面)// 删除 public function del(Request $request){ $id = $request->input('id'); $res = QiyeModel::where('id',$id)->first(); if($res){ QiyeModel::where('id',$id)->delete(); return response()->json(['status'=>200,'msg'=>'删除成功']); }else{ return response()->json(['status'=>500,'msg'=>'删除失败']); } }
2.ajax获取表单参数——————————————————
获取表单里面的所有参数$('#form_edit').serialize()
获取单个参数$('#id').val();
ID为foem_edit tr为第五个 td为第四个 这条数据选中为true('#form_edit tr:nth-child(5) td:nth-child(4)').find('input').attr('checked','true');
跳转链接window.location.href="链接地址"
弹框 如果确定 继续执行confirm('确定要删除所选内容?');
重新加载该页面window.location.reload();
打印内容console.log();
相关文章推荐
- ajax入门的一些基本用法
- JQ AJax基本用法
- ssh,scp的一些基本用法
- Tensorflow的一些基本用法
- ABAP 一些基本用法
- Hibernate中的Query一些基本用法
- Ajax基本用法
- ASP.NET AjaxControlToolkit 的基本用法
- java中的 FileWriter类 和 FileReader类的一些基本用法
- C# Winform TreeView 的一些基本用法
- 文章标题 android服务Service 的一些基本简介和用法
- 黑马程序员————————IO流 FileWriter类 和 FileReader类的一些基本用法
- 在C#应用程序中,对comboBox这个控件的一些基本用法
- 【Java菜鸟 05】java中的 FileWriter类 和 FileReader类的一些基本用法
- NGUI的一些基本用法(及图集字体)
- JQuery dataTable 扩展+Ajax Post,Get一些基本操作(二)
- JQuery Ajax一些基本用法
- Lambda表达式 一些基本用法
- jq的一些基本选择器
- 集合框架Map的一些基本用法