Postingan lainnya
AJAX Uncaught TypeError?
function editForm(id){
save_method = "edit";
$('input[name = method]').val('PATCH');
$('#modal-form form')[0].reset();
$.ajax({
url : "kategori/"+id+"/edit",
type : "GET",
dataType : "JSON",
success: function(data){
$('#modal-form').modal('show');
$('.modal-title').text('Edit Karakter');
$('#id').val(data.id_kategori);
$('#nama').val(data.nama_kategori);
},
error: function(){
alert("Tidak dapet menampilkan data");
}
})
}
tepat nya di sini gan:
$('#id').val(data.id_kategori);
$('#nama').val(data.nama_kategori);
ini cotroller ane :
public function listData()
{
$kategori = Kategori::orderBy('id_kategori','desc') -> get();
$no = 0 ;
$data = array();
foreach ($kategori as $list) {
$no++;
$row = array();
$row[] = $no;
$row[] = $list -> nama_kategori;
$row[] = '<div class = "btn-group">
<a onclick = "editForm('.$list -> id_kategori.')" class = "btn btn-primary btn-sm">
<i class = "fa fa-pencil">Edit</i></a>
<a onclick = "deleteData('.$list -> id_kategori.')" class = "btn btn-danger btn-sm" >
<i class = "fa fa-trash">Delete</i></a>
</div>';
$data[] = $row;
}
$output = array("data" => $data);
return response() -> json($output);
}
yang ane pusing ini program nya jalan tapi dia ga ngedit sesuai id tapi dia malah nge create
0