码迷,mamicode.com
首页 > 其他好文 > 详细

laravel框架之即时更改

时间:2019-10-27 20:53:30      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:sha   res   fun   框架   document   nts   rip   function   script   

表单//
@foreach($res as $k=>$v)
<tr id="{{$v->id}}" >
<td>{{$v->id}}</td>
<td >{{$v->tye}}</td>
<td fd="name" > {{$v->name}}</td>
<td><a href="#" class="shan" id="{{$v->id}}" >删除</a></td>
</tr>
//jqery
<script>
$(document).on("dblclick","td",function () {
fd=$(this).attr("fd");
id=$(this).parents().attr("id");
text=$(this).text();
that=$(this);
if (fd==undefined){
alert("不能修改")
}
html=$(this).html(‘<input type="text" class="gg" value="‘+text+‘">‘)
$(".gg").blur(function () {
new_val=$(this).val();
$.ajax({
url:"zt",
dataType:"json",
type:"get",
data:{
fd:fd,
id:id,
new_val:new_val
},
success:function (data) {
if (data==1){
that.html(new_val)
}
}

})
})
})
</script>

//控制器
function  zt(req $req){
$fd=$req->get("fd");
$id=$req->get("id");
$new_val=$req->get("new_val");
$res= DB::table("ftyp")->where("id",$id)->update([$fd=>$new_val]);
return 1;
}

laravel框架之即时更改

标签:sha   res   fun   框架   document   nts   rip   function   script   

原文地址:https://www.cnblogs.com/azzy/p/11748759.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!