Event-Based AJAX Framework for PHP
Posted on May 18, 2008
Filed Under AJAX |
Articles in this series:
- Introduction to the Framework
- Problems with Creating an Event Based AJAX Callback Mechanism
- JSON data passing
- The Scriptifiable Interface
- The Remotable Interface
This is the first in a series posts on developing an event-based AJAX framework for PHP. There are plenty of AJAX frameworks out there but this one has a few things going for it that others might not:
- Call static functions in any PHP class file that implements the Remotable interface.
- Return javascript representations of PHP objects (with executable javascript functions). Just implement the Scriptifiable interface.
- Don’t worry about stepping on your individual calls. They’re queued automatically and called in FIFO order.
Here’s a quick look at the client side script involved in making a call.
var CallBack = function(returnValue) {
alert(returnValue);
}
var remoter = new Remoter("remoter");
remoter.RemoteInvoke("RemotableClass", "staticFunctionInThatClass", new Array("param1", "param2"), CallBack);
Pretty straight forward. What’s nice is that the returnValue can also be a PHP object which, by the time it gets to your callback, has been turned into a JavaScript object courtesy of JSON. What’s even better is that if that PHP class implements Scriptifiable, the returnValue will also include any functions you specify.
That was just an intro. Check back soon for the second part to this series where we tackle the first part to this problem: Returning Executable JavaScript from an AJAX Call using iFrames.
Comments
6 Responses to “Event-Based AJAX Framework for PHP”
Leave a Reply
[...] Part 1 - introduction, sample usage [...]
[...] Introduction to the Framework [...]
[...] Introduction to the Framework [...]
[...] Introduction to the Framework [...]
[...] Introduction to the Framework [...]
[...] [...]