Code:
jQuery.ajax({
url: 'somefile.php',
type: 'post',
data: {something: 'somevalue'}
});
Then on somefile.php you can do:
PHP Code:
<?php
if(isset($_POST['something']){
// do something here with the value of something, like:
$_SESSION['myval'] = $_POST['something'];
}
?>
That's just an example, you'd need a session_start() before that if it were real. Anyways, you could update a database or whatever with the new value.
With the javascript part you can use an already defined variable in the data part:
Code:
var id = document.getElementById('message').innerHTML;
jQuery.ajax({
url: 'somefile.php',
type: 'post',
data: {something: id}
});
anywhere really, as long as it's a string. There's tons you can do with jQuery.ajax, see:
http://api.jquery.com/jQuery.ajax/
for more info.
Bookmarks