The Nexus
Show navigation Hide navigation
  • BLOG
  • ABOUT
    • Ego Surfing
  • PROJECTS
    • n2
    • S2ajax
    • Condo
    • ezEdit
    • FreeBlog - Air
    • Tooredo Alpha
    • Tools
    • Journlr, Again!
2 Mar 2009 | 2 min. (249 words)

PHP classes and Javascript: S2ajax says "hi()"

S2ajax Logo Sajax is a ‘managed’ AJAX framework that was created by the fine folks at Modern Method a few years ago.
What’s so great about it is the seamless communication between your back-end and the web page itself: you write your PHP code, tell Sajax which functions to export and they are now accessible from Javascript.

For instance – from the ‘example_types.php’ file:

function return_string() {  
    return "Name: Tom / Age: 26";  
}  

The corresponding Javascript call would be:

Return as string  

OK so this is a pretty great package, no doubt.

Unfortunately there are exactly three things that bother me here:

  1. The choice to prefix all remote calls with ‘x_’ which feels less natural, even though it is a convenient way to avoid namespace collisions.

  2. More importantly, Sajax does not support PHP classes and I am not comfortable working with strictly procedural code. After all, object-oriented PHP has been around for quite some time now.

  3. Of course, it would seem that the last Sajax release happened sometime in 2006, which would explain #2

Thus, S2ajax was born.

If supports classes and methods, does not require prefixing and the export() calls are now more powerful.
The syntax is still very straightforward and relies on clean Javascript code.
And the license, obviously, is still the very open BSD.

Additionally, this S2ajax can be easily integrated with PHP 5’s magic class and methods loading. For instance, it works with my own PHP framework.

As usual, all this goodness is available at github.com!

Comments powered by Talkyard.

Twitterified Client v1.3 Almost Ready

Wordpress Toolbar Plugin and Wordpress Prefixes: A Fix

2022 The Nexus