Need pass JS vars to PHP without using <form> <input> <button> w/ AJAX POST method.
Hello.
I'm a newbie in web aplications development and I've been studing in the W3Schools tutorials ( and other places in web ).
I'm using HTML with JavaScript, PHP and MySQL in a Xampp Lite environment.
I want to record in a MySQL table the date and time the visitor entered and left tha page.
I have the two informations stored in string javascript variables.
But although I've found the AJAX, I just can't make it works.
I don't need a form or input HTML tag.
When the visitor call the page, I get the date and time. And when he leave the page ( onunload event ) I get the other date and time and, at this moment I want to pass this JavaScript variable to the PHP script.
Both codes are ok and have been tested separated. The rows are inserted in the MySQL table correctly when I initialize them inside the PHP code.
And in browser-side, with JavaScript, I can see that they ( the variables ) are Ok by displaying it.
Bookmarks