I have to make a stupid mistake, but I cannot return the data received from the $ .post function and store it in a variable, and not only I can not return ANYTHING from this function. Example:
function test(){ $.post("demo_test_post.asp", { name:"Donald Duck", city:"Duckburg" }, function(data,status){ return(data) }); } var foo = test() alert(foo)
he says foo is undefined. But do it even further, even when I do it:
function test(){ $.post("demo_test_post.asp", { name:"Donald Duck", city:"Duckburg" }, function(data,status){ var bar = "bar" return(bar) }); } var foo = test() alert(foo)
this STILL says foo is undefined ... I have to do something wrong or misunderstand something. Maybe someone can help.
thanks
source share