I will share my half written/half pseudo code in hopes that someone will help me fill in the pieces.
I have a div
named results
. When a click is made inside of the results
div, I need to send a POST request to update a table row in my DB.
$(function() {
$("body").click(function(e) {
if (e.target.id == "results" || $(e.target).parents("#results").size()) {
// add timer clicks must be at least 15 seconds apart or do not POST
// a click was made in the results div, record click to record in db
ajax_post();
}
});
})
This code appears to work, however, I am getting a warning alert *event.returnValue is deprecated. Please use the standard event.preventDefault() instead. *
Moving on, my ajax_post
function seems to NOT be functioning.
function ajax_post(){
var x = new XMLHttpRequest();
var url = "tq/--record-events.inc.php";
var session = //get session information from cookie
var data = "ClickCount="+1+"&SessionId="+session;
x.open("POST", url, true);
x.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
x.send(data);
}
Once I get the vars to POST to my php script - I can take it from there, just having a little bit of trouble getting there. I appreciate the help. Thank you.