I basically want to have a function which is GET'ing a page and then returns a result based on that, this leads to the following problem:
All GET methods are using a callback function, meaning that the function will end before the result is there. How do I pause the thread until the callback is fired and then return the result of the callback in my main function?
function someFunction(){
$.get(
"blabla.php",
function(data) {
// This data is supposed to be returned by "someFunction"
}
)
return //the data we retrieved from 'blabla.php'
}
How would you accomplish this?
EDIT: I know this concept from lua, however I'm not entirely sure if someone would call it "Yielding a function result". Please correct me, if I'm wrong.