I have a script that will check a file, then the file returns 1 or 0. But even if it returns 1 the script alert the else. Why does this dont work?
When i alert txt it show 0 but when the txt is 1 the alert(txt) gives me 1.
So my question is, why does not hi! comes up when txt is 1?
$(document).ready(function(){
setInterval(function(){
//code goes here that will be run every 5 seconds.
var txt = '';
$.ajax({
type: "POST",
url: "checkfolder.php",
success: function(result) {
txt = result + '';
if (txt == "1"){
alert("Hi!");
}
else{
alert(txt);
}
}
});
}, 5000);
});
Aucun commentaire:
Enregistrer un commentaire