Sort of like this:
function getfoo() {
var foo = "";
$.get("foofile.html", function (data) {
foo = data;
});
return foo;
}
But then since the script is asynchronous, it will return "". That's obviously not what I want.
So then I tried this:
function getfoo() {
var foo = "";
$.get("foofile.html", function (data) {
foo = data;
});
for (;;) {
if (foo != "") {
return foo;
break;
}
}
}
And I expected that to work, but it didn't. Why not? And can someone suggest a solution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…