我是创建更新和删除,但是我通过ID查看数据时出错。请帮我 :
这是我的script.js
function dataModal(){
var tableDatas = $("#datas");
var route = "http://localhost:8000/dataLowongan";
$("#datas").empty();
$.get(route, function(res){
$(res).each(function(key,value){
tableDatas.append("<tr><td>"+value.id+"</td>"+
"<td>"+value.judul+"</td>" +
"<td><button value="+value.id+" onClick='EditModal(this);' class='btn btn-primary' data-toggle='modal' data-target='#myModal'>Edit</button>"+
" <button value="+value.id+" onClick='HapusModal(this);' class='btn btn-danger' data-toggle='modal' data-target='#dellModal'>Hapus</button>"+
" <button value="+value.id+" onClick='ViewModal(this);' class='btn btn-default' data-toggle='modal' data-target='#viewModalBlade'>View</button></td></tr>"
);
});
});
}
这是View的功能
function ViewModal(btn){
var route = "http://localhost:8000/lowongan/"+btn.value+"/edit";
$.get(route, function(res){
$("#id").val(res.id);
$("#judul").val(res.judul);
});
}
我收到错误,我的modal.blade查看视图数据。
<div class="modal fade" id="viewModalBlade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-body">
{{ $datas->judul}}
</div>
</div>
</div>
</div>