I am doing next...
request in php from html (jQuery)
$.post("index.php?res=ok", { username: user, userpass: pass }, function(data) {
$("#signin_ok").html("You sign in now "+data.name+". Your password is: "+data.pass);
$("#signin_ok").show()
.animate({fontSize:"120%"}, 100).css({color:"#32CD32"})
.animate({fontSize:"100%"}, 100)
.animate({fontSize:"100%"}, 3000)
.animate({fontSize:"120%"}, 200, function() {
$(this).css({display:"none"});
});
});
return from php in html (jQuery)
if(isset($_REQUEST['res']) && $_REQUEST['res'] == "ok") {
if(isset($_POST['username']) && isset($_POST['userpass'])) {
$username = $_POST['username'];
$userpass = $_POST['userpass'];
echo json_encode(array("name" => $username, "pass" => $userpass));
}
}
but returns "You sign in now undefined. Your password is: undefined"
What's wrong? How to fix it?
P.S.
When I add "json" like this
$.post("index.php?res=ok", { username: user, userpass: pass }, function(data) {
. . . . . .
. . . . . .
}, "json");
no reaction
What was going on???
{"name":"sabotagnik","pass":"66666666666666"}I'll must eval() it in PHP or in JS? If in PHP:$arr = array("name" => $username, "pass" => $userpass); eval("\$arr = \"$arr\";"); echo json_encode($arr);and result is"Array"