There is a guest book. Textarea and button. On php did, it works. But I wanted to add ajax so that the page does not reload.

How can I tell javascript'u user id?


I'll get better. How to do the same, if the javascript itself in the included file?

    2 answers 2

    Make the request so, and in php already understand the session, what id the user has.

    • For sure! And I was thinking how to convey. Everything is much simpler) - oleg_ismaylov

    one.

    Ajax: <?php echo $userId; ?> 

    2

     Ahah: <?php echo "var userid = ".$userId; ?> 

    The easiest way. JSON, XML and others are already harder =)