I have a Grid with the edit button when I click on it it accesses the Controller and brings the data into a Json and "Theoretically" was to return that data in a Modal.
When I type Url .... show / (ID) the Json data appears but I am not able to make this data appear on the Modal Form.
Follow the Code
HTML (Button and Inputs where data was to appear)
<a href="#" onclick="GetAlunoDetails('{{$valor->id}}')" data-target="#editModal" data-toggle="modal">{{ $valor->nome }}</a>
<input type="text" class="form-control" id='nometeste' name="nometeste" value="">
<input type="text" class="form-control" id='idteste' name="idteste" value="">
<input type="hidden" id="hidden_user_id">
JS
function GetAlunoDetails(id) {
$("#hidden_user_id").val(id);
$.get("/.../alunos/show/"+id, {
},
function (data) {
// PARSE json data
var aluno = JSON.parse(data);
// Assing existing values to the modal popup fields
$("#nometeste").val(aluno.nome);
$("#idteste").val(aluno.id);
}
);
// Open modal popup
$("#editModal").modal("modal");
}
CONTROLLER
public function show($id)
{
//Pegando os valores para preencher a tabela
$aluno= $this->aluno
->select('*')
->find($id);
return response()->json($aluno);
}