I have a code that forms the user's profile screen. On the side of the name it has the edit option, which when clicked opens an inline edit ( form-x-editable.html ). Even in that part it is working normally, but clicking to save it gives the error NetworkError: 500 Internal Server Error . I do not know what could be wrong. My code is in MVC
View:
<span rel="tooltip" data-placement="right" data-original-title="Nome">
<a href="form-x-editable.html#" style="font-size: 14px;" id="nome" data-type="text" data-placement="top" data-pk="14" data-original-title="Nome">Editar</a>
</span>
Javascript:
var nome;
nome = '<?= $dados->nome ?>';
$('#nome').editable({
url: '/Controller/editar',
type: 'text',
pk: 14,
name: 'nome',
title: 'Nome',
params: function (comp) {
comp.id_span = 'span14';
comp.id = di_id;
comp.e_id = epr_id;
return comp;
},
ajaxOptions: {
type: 'GET',
dataType: 'json',
contentType: 'application/json'
},
success: function (j) {
$('#span14').html(j.nome);
$('#dispName').empty();
$('#dispName').html(j.nome);
},
value: nome,
display: false
});
Controller:
public function editar(){
switch($this->input->get('id_span')){
case 'span14':
$data['nome'] = $this->input->get('value');
$id = $this->input->get('id');
$e_id = $this->input->get('e_id');
$this->session->set_userdata('nome',$this->input->get('value'));
$this->MT->editPerfil($id,$e_id,$data);
break;
}
echo json_encode($data);
}
}
Model:
public function editPerfil($id, $e_id, $data) {
if ($this->vrfUsrEmp($e_id)) {
if (isset($data['nome'])) {
$this->db->set('nome', $data['nome']);
}
$this->db->where('id', $id);
$this->db->where('e_id', $e_id);
$this->db->update('NomeTabela');
return $this->db->affected_rows();
} else {
return false;
}
}