当前位置: 移动技术网 > IT编程>开发语言>Jquery > laravel框架之即时更改

laravel框架之即时更改

2019年07月15日  | 移动技术网IT编程  | 我要评论
表单//@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=" ...
表单//
@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;
}




如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网