Ankündigung

Einklappen
Keine Ankündigung bisher.

Periodisch updaten

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Periodisch updaten

    Hey,

    ich habe folgendes Script:
    Code:
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    	</head>
    	<body>
    		<script src="http://code.jquery.com/jquery-latest.js"></script>
    		<script>
    		
                     $.get("ajax.php", function(data){
                      var duce = jQuery.parseJSON(data);
                     var x = duce[0];
                     var y = duce[1];
    
                    console.log(x);
                   console.log(y);
            });
                  setInterval(function(data),1000);
    </script>
    	</body>
    </html>
    Und will das ganze Ding einfach periodisch updaten. Nur leider bekomme ich das nicht ganz so hin, wie ich will. Kann mir da jemand helfen?

  • #2
    Habe es hinbekommen, so sieht es aus:
    Code:
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    	</head>
    	<body>
    		<script src="http://code.jquery.com/jquery-latest.js"></script>
    		<script>
    (function worker() {		
    	$.get("ajax.php", function(data){
    	var duce = jQuery.parseJSON(data);
    	var x = duce[0];
    	var y = duce[1];
    
    	console.log(x);
    	console.log(y);
     	
    	});
    	setTimeout(worker, 5000);
    })();
    
    
    </script>
    
    	</body>
    </html>

    Kommentar

    Lädt...
    X