David Doran Media

Search


Sajax Modification Open Source

Sajax is a nice little AJAX library created by Modern Method. The library is quite small and very easy to set up but I didn't like the way it was orientated around serving the back-end code in the same page as the front-end. (This is very useful for beginners though)

So, what I have done is split the library into a front-end static JavaScript file and a back-end PHP file. This way there is no overhead when serving the JavaScript file, and you can reuse the same back-end file.

Here is handle_ajax.php which sends the server response:
The back-end Sajax has been edited to be Object-orientated:

 
<?php
function get_message_time()
{
        return( date('H:i jS M Y').'And a little message!!' );
}
 
// Sajax made ... easier //
require("Sajax.php");
$sajax = new Sajax( );
$sajax->export("get_message_time");
$sajax->handle();