Estoy usando: echo json_encode ($ Response); para enviar una matriz asociativa a JQuery Ajax. Cada vez que trato de leer cada valor de clave de identificación obtengo un valor indefinido. Por favor, ayudarme a averiguar lo que estoy haciendo tan mal ... Gracias de antemanoForma correcta de leer 'echo json_encode()' de JQuery
Mi Código PHP:
$Stuff = 'Hello world';
$Success = true;
$Content = $Stuff;
$Response = array('Success' => $Success, 'Content' => $Content);
echo json_encode($Response);
# #
Mi código JS:
var sFirstName = $('#student_first_name').attr('value');
$.ajax({
type: "GET",
url: "../pgs/UpdateEditAStudent.php",
data: "FirstName="+ sFirstName ,
//The below code will give me: {"Success":true,"Content":"Hello world"}
success: function(data){$("#Ajax_response").html(data);}
//The popup window will show me "Undefined"
//and: {"Success":true,"Content":"Hello world"}
success: function(data){$("#Ajax_response").html(data); alert(data.Content);}
});
Javascript 'arrays' con llave valor =>? – Niklas