Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JS][jQuery] Problem setTimeout, [SOLVED]
angel2953
post
Post #1





Grupa: Zarejestrowani
Postów: 199
Pomógł: 5
Dołączył: 8.07.2004
Skąd: gdynia

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


mam sobie takie kodzik, który korzysta z jQuery 1.2.1:
  1. jQuery(document).ready(function() {
  2. var clock_fcj = function() {
  3. var _curDate = new Date();
  4. var _nextHour = _curDate.getHours() + 1;
  5. var _nowMinutes = 60 - _curDate.getMinutes();
  6. var _nowSeconds = 60 - _curDate.getSeconds();
  7.  
  8. _nowMinutes = ( _nowMinutes < 10 ) ? _nowMinutes = "0" + _nowMinutes : _nowMinutes;
  9. _nowSeconds = ( _nowSeconds < 10 ) ? _nowSeconds = "0" + _nowSeconds : _nowSeconds;
  10. jQuery("#clock").replaceWith( "reset apache'a " + _nowMinutes + ":" + _nowSeconds );
  11. setTimeout( "clock_fcj", 1000 );
  12. }
  13. clock_fcj();
  14. });

i on powinien wyświetlać odliczający "zegarek" w divie i częściowo to działa bo po załadowaniu strony pokazuje ilość minut:sekund ale po przejściu pierwszej pętli setTimeout w FireBug'u znajduje taki komunikat:
Cytat("FireBug")
clock_fcj is not defined
setTimeout( "clock_fcj", 1000 );

czy ktoś może mi powiedzieć co ja robię źle ?

Ten post edytował angel2953 23.10.2007, 14:18:40
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
gekon
post
Post #2





Grupa: Zarejestrowani
Postów: 614
Pomógł: 7
Dołączył: 10.11.2003
Skąd: Rzeszów/Kraków

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


@nospor: Nie trzeba nic wywalać (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)
@angel2953: Z tego co sie orientuję, to jQuery nie ma takiej metody jak replaceWith(), zamiast nie użyj metody text():
  1. jQuery("#clock").text( "reset apache'a " + _nowMinutes + ":" + _nowSeconds );
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: 8.10.2025 - 11:43