Вот простой пример, когда объект javascript отправляется с одной веб-страницы на другую. В этом случае объект отправляется в параметрах GET запроса.
Первый пример отправит объект при нажатии на ссылку
<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>
И файл test.php может обрабатывать объект, и при загрузке страницы объект становится доступным.
<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>