first sorry for my bad english. I am from a Hispanic country. I am new to website development, so I have a web project in my hands and am having problems with this requirement.
In the index () function of the controller, I need to grab the ID attribute, which conveys the thought, such a link:
echo '<td><a class="btn btn-default" role="button" data-toggle="modal" href="#edituser" data-href="admin/editar/' . $usuario->id . '"><i class="glyphicon glyphicon-edit"></i> Editar</a></td>';
So he can run
$data['editar_instructor'] = $this->user->obtener_datos_por_id($id);
and it can show user data that I'm trying to edit. I already have a JS code that captures Modal form data and saves it in the database.
$(document).ready(function(){
$('#edituser').submit(editUser);
});
function editUser(event)
{
event.preventDefault();
var form_data = {
username : $("[name='username']").val(),
password : $("[name='password']").val(),
repassword : $("[name='repassword']").val(),
JCCE : $("[name='JCCE']").val(),
fullname : $("[name='fullname']").val(),
privilegios : $("[name='privilegios']").val()
};
var action = $(this).attr('data-href');
$.ajax({
url: action,
type: "POST",
data: form_data,
dataType: "json",
cache: false,
success: function (json) {
if (json.error==1)
{
$('#EditUserError').html(json.message);
} else {
$('#edituserform').slideUp();
$('#EditUserError').html(json.message).show();
}
}
});
}
which works fine already, but I don’t know how to get Modal to load the data of a specific user.
Any suggestion, idea, critique, etc ?? I will appreciate everything. Thanks in advance!