Ok, so I’m trying to store users’ key presses in a database, but so far I had no luck. I have the following JavaScript code:
$(document).bind('keypress', function (event) {
$.post('processPost.inc.php', { "valueToStore" : event.which } );
}
Then, I have my processPost.inc.php PHP file, with the following code:
<?php
if (isset($_POST['valueToStore'])) {
storeIntoDatabase(sanitizeInput($_POST['valueToStore']));
}
I know that the event detection itself works, that the storeIntoDatabase and sanitizeInput functions and everything else works, but I’m almost certain that I’m using jQuery‘s $.post in the wrong way (or there’s a typo somewhere but that wouldn’t be so hard to fix, just a pain in the ass).
I’d like to know how to use it in this specific situation. I’ve been looking up $.post examples and all, and every example I found talks about forms and serializing, but in this case there is no form at all. Can anyone help me with this?
According to the doc: [source]
In a map, the key should not be wrapped with quotes: