I must be making a silly mistake but I cannot return the data I get from a $.post function and store it in a variable, not only that, I cannot return ANYTHING from within that function. Example:
function test(){
$.post("demo_test_post.asp",
{
name:"Donald Duck",
city:"Duckburg"
},
function(data,status){
return(data)
});
}
var foo = test()
alert(foo)
it say's that foo is undefined. But to take it a step further, even when I do this:
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)
it STILL says foo is undefined... I must be doing something wrong or misunderstanding something. Can someone please help.
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…