trying to send the javascript variables x and y from play.php in a PHP page xyz.php using AJAX but not being able to do so. could you guys be kind and tell me what's wrong here?
function clicked(evt){
var e = evt.target;
var dim = e.getBoundingClientRect();
var x = evt.clientX - dim.left;
var y = evt.clientY - dim.top;
$( document ).ready(function() {
$.ajax({
type: "POST",
url: 'play.php',
data: {X: x },
success: function(data)
{
alert("success! X:" + data);
}
});
});
}
and in xyz.php
<?php
if (isset($_GET["X"])) {
$x = $_GET["X"];
echo $x;
}else{
echo 'no variable received';
}
?>