Have you alreday tried PRAjax?

Edit on GitHub

Some people who know me, have already experimented with my home-brew PHP Ajax framework, PRAjax. PRAjax is short for PHP Reflected Ajax, and provides the glue between server-side PHP and client-side Javascript. You should really try it out in your project!

My blog uses PRAjax too. Try navigating to the homepage and clicking a [more...] link. The article body is then fetched behind the scenes and updated on your browser view.

A small example...

One can write a method in PHP, and make it callable by the client using JavaScript. For example, you have the following PHP code:

function Hello($pName = '') {
return 'Hello, ' . $pName;
}

On the client-side, you can now call this method asynchronously (using, for example, a link with an onclick method "Hello('Maarten');", and get the result in a callback function:

function Hello_cb (pData) {
if (pData != null) {
alert(pData);
}
}

That's all there is to it! It's even possible to pass objects between PHP and JavaScript.

Currently, I'm considering porting this to ASP.NET but I do not expect much interest because of Atlas, which offers much more options combined with a complete ASP.NET-alike object model.

This is an imported post. It was imported from my old blog using an automated tool and may contain formatting errors and/or broken images.

Leave a Comment

avatar

0 responses