11
that 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 precise case the return value of the Ajax function, which always returns Undefined.
This function returns a small Json object which will then be manipulated elsewhere.
For now, to resolve this issue I used a public variable, 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 within the $.ajax function itself();
What other type of language are you making an ajax call for? PHP? ASP? Your mistake is at
url
, because it is waiting for you to send the request to a function, or file, which in turn will have a Return– CesarMiguel
Actually the returned Json will be used within the javascript itself and by the way the language I am using is Java.
– Fabio Macedo