this is the code:
var res = VerFileRepetidoBancoAjax( "teste" );
console.log("res="+res);
function VerFileRepetidoBancoAjax( str ){
$.ajax({
url: "caminho.",
type: "get",
dataType:"json",
data: "dado="+ str,
async: false,
success: function( data ){
return data;
}
});
}
In this case I need the return value of the Ajax function, which always returns undefined . This function returns a small Json object that will later be manipulated elsewhere.
By hour, to solve this issue I used a public variable, it follows:
/* declaro uma variavel publica */
var res ;
VerFileRepetidoBancoAjax( "teste" );
console.log("res = "+res);
function VerFileRepetidoBancoAjax( str ){
$.ajax({
url: "caminho.",
type: "get",
dataType:"json",
data: "dado="+ str,
async: false,
success: function( data ){
/* aqui coloca o OBJ dentro da variavel publica*/
res = data;
}
});
}
There is a form inside the function $ .ajax ();