On Apr 11, 5:07 am, fajnalowiec <[email protected]> wrote:
> I must say big "WOW". I am really, really impressed. Thanks a lot
> :D I spent a few hours fruitlessly looking for solutions and it was
> so close.
> For future JS development I have one more question;
>
> with a code like this:
>
> function f() {
>   ...
>   geocoder.geocode(...
>   if (status == google.maps.GeocoderStatus.OK) {
>     //some stuff
>   }
> );
> document.myform.submit();
>
> }
>
> why submit of the form is done and execution of "//some stuff" is
> omited?
> AFAIU, in this case the form submit is done earlier. Why JS
> doesn' t wait for finish method geocode()?

Geocoding is asynchronous.  It sends a request off to the server,
continuing execution of your code (not waiting), when the response
comes back containing the data, the callback routine runs (the "some
stuff"), but by then your submit has already been executed.

You need to put any code that depends on the returned data _inside_
the callback routine.

  -- Larry

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to