Basically what I want to do is get string result from a URL. the result I get when I use my browser on the URL can be as simple as the string "word dog cat dog".
I'm trying to use the following:
var textwords;
d3.text(myUrl, function(data) {
textwords = data;
});
and later on using textwords
somehow in the following lines, but I can't of course because the callback function executes after all other code.
is there any way (other than putting all of the following code inside the callback function) I can manage to use textwords
after it gets the data?
Thank you!
Unfortunately the short answer is no. The long answer is also no, but you could make things look a little nicer by using jQuery's Defferred . There is a really good introduction here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.