I have the JS code below and the JSON return does not assign the value to the variable texto
. I ran a test with alert(data.frase)
and the message came normally.
Does anyone know why var texto
does not get the value of data.frase
?
var texto=null;
var cod = { cod: codFrase };
$.ajax({
url: "/Motivos/Getfrase",
type: 'Post',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(cod),
success: function (data) {
if (data.success) {
texto = data.frase;
}
}
});
Thank you