Reputation: 12512
Is there a way to set a session variable from withing my JS function?
I have the following JS code:
$.ajax({
url: "ajax.php",
type: "POST",
data: {
tid: '.$testID.',
do:"'.$do.'"
},
success: function( html ) {
$("#partBox").html( html );
// add PHP here?
}
});
I would like to set the following var in the session, on SUCCESS:
$_SESSION['hgt'] = 'Math.ceil($("#partBox").height() / 2)';
I have no idea if this is even possible... Alternatively I could probably use cookies...
Upvotes: 0
Views: 1715
Reputation: 219804
You can't set any PHP variables in JavaScript. Once the Page has finished loading PHP has done its job and is out of the picture. If you want to set a session variable using JavaScript you can do it one of two ways:
Upvotes: 5