I am doing a google distancematrix call and having a problem that my code continues before I have the distance being calculated. breaking my next calculation as there is no distance to compute against. Does anyone know how to make the script wait for the response from google before continuing with the next action?
Asked
Active
Viewed 29 times
0
-
Continue doing work in the "complete" handler. The code that invokes the google call *cannot* be blocked (sort of using a synchronous AJAX request) so the structure of the program must be changed to fit the asynchronous model. See http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call (a different question, but the same concept). – user2864740 Aug 11 '14 at 19:23
-
I guess this goes into the direction of [Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference](http://stackoverflow.com/questions/23667086/why-is-my-variable-unaltered-after-i-modify-it-inside-of-a-function-asynchron) – Felix Kling Aug 11 '14 at 19:27