My query is as follows, my code is:
$("#sPedido").change(function(){
var codigo_c=$("#sPedido").val();
$.post("traertabla.php", function(datos){
$("#midiv").html(datos);
alert(datos.mensaje);
});
});
The line:
$("#midiv").html(datos);
shows me the data on the screen without any problem, the result is:
{"mensaje":"hola"}
But, when executing this line:
alert(datos.mensaje);
the alert only shows me: "undefined"
.
At what point did I make the mistake?