Answer the question
In order to leave comments, you need to log in
How to process json server response on client?
Hello.
There is a button:
<a href="#" data-toggle="modal" data-target="#editUser" onclick="idUser(<?=$data->id;?>)"><span class="glyphicon glyphicon-pencil"></span></a>
<script>
function idUser(id) {
$.ajax({
type: 'POST',
url: '/frontend/users_admin/delete',
data: id,
success: function(data) {
console.log(id);
}
});
}
</script>
public function edit($id)
{
if ($data = $this->users_admin_model->get_data_user($id))
{
return json_encode($data);
}
else
{
return FALSE;
}
}
Answer the question
In order to leave comments, you need to log in
You get an array of
$(document).on('click', '[data-toggle="modal"]', function () {
$.ajax({
url: '/frontend/users_admin/delete',
type: 'POST',
dataType: 'json',
data: $(this).data('id')
}).done(function(data) {
console.log(data, data.length);
for (var i = 0; i < data.length; i++) {
console.log(data[i]);
}
}).fail(function(error) {
console.log(error);
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question