עכשיו יש בעיה אחרת
יש לי דף, out.php
PHP קוד:
<?php
if($_GET['i']>=10){
echo "DONE";
} else {
$i=$_GET['i']+1;
echo $i;
}
?>
ואת הקוד
קוד:
var http;
var out;
function engine(){
var http=null;
try{
// Firefox, Opera 8.0+, Safari
http=new XMLHttpRequest();
} catch(e){
try{
// Internet Explorer
http=new ActiveXObject("Msxml2.XMLHTTP");
} catch(e){
// Internet Explorer
http=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return http;
}
function ready(){
if(http.readyState==4){
out=http.responseText;
}
}
function send(i){
http=engine();
if(http==null){
alert("Your browser does not support AJAX!");
return;
}
http.onreadystatechange=ready;
http.open("GET","out.php?i=" + i,true);
http.send(null);
}
function play(i){
out=i;
while(out!="DONE"){
send(out);
document.getElementById("output").innerHTML=document.getElementById("output").innerHTML + "|";
alert(out);
}
}
עובד פרפטק, מראה 10 קווים
מוריד את הalert הלולאה לא נגמרת
מה לעשות?