Here is an simple example where a javascript object is sent from one web page to another. In this case the object is sent in the GET parameters of the request.
The first example will send the object when the link is clicked
<html>
<head>
<script src="../prototype.js" type="text/javascript"></script>
<script type="text/javascript">
Event.observe(window, 'load', function() {
sendObject=function(el){
var myObj = eval('(' + this.readAttribute('obj') +')');
window.location = 'test.php?obj='+ this.readAttribute('obj');
}
$('sendobj').observe('click',sendObject);
});
</script>
</head>
<body>
<div id="sendobj" foo="bar" obj="{'id':'3','name':'fred'}">
Send the object
</div>
</body>
</html>
And the file test.php file can process the object and when the page loads the object is available.
<html>
<head>
<script src="../prototype.js" type="text/javascript"></script>
<script type="text/javascript">
Event.observe(window, 'load', function() {
var person=<?php echo $_GET['obj'] ?>;
//and now the object is available in the page that we arrived at
alert('My name is ' + person.name);
});
</script>
</head>
<body>
The object is here now
</body>
</html>