Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> kolejność wykonywania kodu
zazdrosny17
post
Post #1





Grupa: Zarejestrowani
Postów: 55
Pomógł: 0
Dołączył: 24.07.2010

Ostrzeżenie: (0%)
-----


  1. function pokliknieciu(){
  2.  
  3.  
  4. var x1 = 2;
  5.  
  6. function haha(x)
  7. {
  8.  
  9. var address = x;
  10. geocoder.geocode( { 'address': x}, function(results, status) {
  11. if (status == google.maps.GeocoderStatus.OK) {
  12.  
  13. x1 = 1;
  14.  
  15. alert("alert 2 to "+x1);
  16.  
  17. } else {
  18.  
  19. x1 = 0;
  20. }
  21. });
  22.  
  23. if(x1 != 2)
  24. {
  25. return x1;
  26. }
  27. else
  28. {
  29. haha(address);
  30. }
  31. }
  32.  
  33.  
  34.  
  35.  
  36. var x == $("#x").val();
  37. var x2 == $("#x2").val();
  38.  
  39. x1 = haha(x);
  40.  
  41.  
  42. alert("alert 1 to "+x1);
  43.  
  44. if(x == 0)
  45. {
  46. alert("x == 0");
  47. }
  48. else if(x1 == 0)
  49. {
  50. alert("x1 ==0);
  51. }
  52. else if(x2 == 0)
  53. {
  54. alert("x2 ==0);
  55. }
  56. else
  57. {
  58. //dalszy kod
  59. }



alert 1 is undefined

alert 2 to 1


najpiew wykonuje się dalsza część kodu a dopiero poźniej mam wynik z tej funkcji. jak mogę to rozwiązać (IMG:style_emoticons/default/questionmark.gif) ?

Ten post edytował zazdrosny17 20.09.2013, 12:03:15
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 15.09.2025 - 09:09