The biggest difference is that this example _doesn't use_ the json.js
library since Prototype 1.5.1.x supports json.
Files needed to test this example:
Demo.ashx ,part of the jayrock distribution: http://jayrock.berlios.de/
prototype.js (I'm using version 1.5.1.1): http://prototypejs.org/
BTW, the examples was hacked together last night, I bet a Protoype
'guru' could do a better job.
<head>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="http://localhost/jayrock/Demo.ashx?
proxy&v=2"></script>
<script type="text/javascript">
/* <![CDATA[ */
function protoChannel(call) {
return new Ajax.Request(call.url + '/' + call.request.method , {
method:'get',
parameters: 'id=' + call.request.id + '¶ms=' +
call.request.params + '&rand=' + Math.random(9999),
onSuccess: function(transport){
var json = transport.responseText.evalJSON(true);
call.callback(json.result);
}
});
}
var objTest = {
init : function() {
// set local object vars here
this.run();
},
run : function() {
// run bulk of behavior here
DemoService.rpc.now(this.fillDiv).call(protoChannel);
},
fillDiv : function(result) {
// Setup callback function
$('divReturn').innerHTML = result;
}
}
function initializer() {
objTest.init();
}
Event.observe(window, 'load', initializer, false);
/* ]]> */
</script>
</head>
<body>
<div style="border: solid thin grey; margin: 10px; padding: 10px;"
id="divReturn"></div>
</body>