Hi I am doing one checkscript with jquery and php
I have written this :
$.post("chatController.php", {
ssha:"<?php echo $sechs1;?>",
user: "<?php echo $_SESSION["username"];?>",
class:1
}, function(data){
$.each(data, alert(this));
}, "json");
And from the PHP file I get something like :
echo json_encode(array("John","2pm"));
This array can have 0,1,2….unlimitied entries..
How I alert each of this entrie one by one ?
Perhaps something like:
For each data > alert(this)
You are calling
alertimmediately and passing its return value to$.each. You have to pass a function reference instead:Be careful with using
classas property name. It is a reserved keyword and you could have problems with it in browsers. Either put it in a string:or rename it.