I have found many forums and texts where they explain it in detail, the problem is that nothing works for me and I have tried it in many ways. I leave you the JSON and how I try to read it without having different results from:
application.js: 29 Uncaught ReferenceError: content is not defined at HTMLButtonElement. (application.js: 29) at HTMLButtonElement.dispatch (jquery-3.1.1.min.js: 3) at HTMLButtonElement.q.handle (jquery-3.1.1.min.js: 3)
Thanks in advance for your response.
[ { 0: "14460243",
1: "",
2: "RICARDO RAFAEL ",
3: "VILLAGRANA LARIOS",
4: "VILLAGRANA",
5: "LARIOS",
ncont: "14460243",
mtricula: "",
nombre: "RICARDO RAFAEL ",
apellido: "VILLAGRANA LARIOS",
AP: "VILLAGRANA",
AM: "LARIOS" } ]
and this is my code with which I intend to read:
$('#load-more').click(function(){
$.get('api/fields.php?code=show',function(data){
var content = JSON.parse(data);
console.log(content)
})
alert(content[0].nombre)
});
This is executed when I press a button
<button id="load-more" style="margin: 150px;" class="btn btn-color-2"> <i class="fa fa-refresh"></i> Cargar más </button>