在PHP会话中保存jQuery变量
问题描述:
var x = e.pageX;
var y = e.pageY;
Which is the easiest way to save those jQuery variables in a PHP session.
var x = e.pageX;
var y = e.pageY;
code> pre>
这是在PHP会话中保存这些jQuery变量的最简单方法。 p>
div>
答
$.ajax({
url: '/update-session.php',
data: {"x":e.pageX,"y":e.pageY},
type: 'post',
success:function(data){
// if you care.
}
});
update-session.php:
$_SESSION['pageX'] = $_POST['x'];
$_SESSION['pageY'] = $_POST['y'];
答
Make an AJAX request to a PHP page that saves them in the session.