Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [AJAX][JavaScript][PHP] Automatyczne odświeżanie treści
EdeusEx
post 3.05.2010, 18:39:10
Post #1





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 6.04.2008

Ostrzeżenie: (20%)
X----


  1. <?
  2. echo $_POST["vars"];
  3. ?>


  1. function execute(vars, div_id) {
  2. $.ajax({
  3. url: 'system.php',
  4. dataType: "html",
  5. type: 'POST',
  6. data: "vars="+vars,
  7. timeout: 1000,
  8. success: function(html){
  9. $("#"+div_id).html(html);
  10. }
  11. });
  12. }
  13.  
  14. function getWorldActions() {
  15. execute('nothing', "world_msg");
  16. setInterval(getWorldActions, 5000);
  17. }


Strona się zawiesza po pewnym czasie. Co zrobić, żeby się NIE zawieszała?
Go to the top of the page
+Quote Post
nospor
post 3.05.2010, 22:52:39
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Doczytaj w necie ze zrozumieniem co robi setInterval() - moze zrozumiesz czemu ci się strona zawiesza winksmiley.jpg


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
EdeusEx
post 5.05.2010, 11:34:59
Post #3





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 6.04.2008

Ostrzeżenie: (20%)
X----


setTimeout() jest jeszcze gorszy, bo strona zawiesza się od razu. Jak naprawić ten kod - nie wiem. Przyznaję się bez bicia.
Go to the top of the page
+Quote Post
nospor
post 5.05.2010, 12:14:28
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




A pokaż nowy kod z tym setTimeout


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
EdeusEx
post 5.05.2010, 16:05:18
Post #5





Grupa: Zarejestrowani
Postów: 49
Pomógł: 1
Dołączył: 6.04.2008

Ostrzeżenie: (20%)
X----


  1. function getWorldActions() {
  2. execute(0, "world_msg");
  3. setInterval(getWorldActions(), 5000);
  4. }
  5.  
Go to the top of the page
+Quote Post
nospor
post 5.05.2010, 18:54:11
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




blinksmiley.gif Przecież tu nadal jest setInterval()....


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 4.07.2025 - 17:23