- Jul 18, 2002
- 1,655
- 1
- 81
I have some JS code below:
Two questions :
1. How do I get access to the data variable outside of the get function ? The variable outside is not being assigned.
2. How can I (or should I, am I thinking about this wrong ?) wait for the
I remember vaguely this has something to do with the non-blocking nature of JS. Right now all of my calculations code is living inside the
JavaScript:
var outside = 0;
$.get("demo_test.asp", function(data, status){
alert("Data: " + data + "\nStatus: " + status);
outside = data
});
outside = outside + 1;
// more calculations
Two questions :
1. How do I get access to the data variable outside of the get function ? The variable outside is not being assigned.
2. How can I (or should I, am I thinking about this wrong ?) wait for the
.get()
block to finish processing before moving on to my outside = outside + 1;
assignment ?I remember vaguely this has something to do with the non-blocking nature of JS. Right now all of my calculations code is living inside the
.get()
block...which is fine until I need to call another .get()