Majax: maSnun's ajax library

Inspired by “sajax”, here I write “majax”. It’s simpler and effective.

The library is written in PHP that lets you add ajax functionality without coding a single line of javascript. Currently it can fetch text data over the GET method and update a HTML DOM element with that data.

Download: http://masnun.googlecode.com/files/majax.zip

A sample demo code snippet can be found at http://dpaste.de/j7eb/

The concept is very simple, just inside your HTML head tag, open up a <script> tag. Now use “majax_init()” to initiate the ajax engine. Now use the “majax_get()” function like this:

majax_get(url,element_id,refresh_time);

Example: majax_get(“majax_test.php?view=maSnun”,“masnun”,1000);
This line would fetch the data at “
majax_test.php?view=maSnun” and replace the HTML of the element “masnun” with the data. And this entire process will repeat every 1000 mili seconds that is every second.

The “refresh_time” parameter is optional. You can ignore this one if you don’t want the function to execute repeatedly.

Use like this: majax_get(“majax_test.php?view=maSnun”,“masnun”);

This would process the request only once.

PS: I am going to work more on this. If you think this is useful or at least rubbish, let me know. Any suggestions and logical criticism is most welcome.


This entry was posted in Blog Post and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">