Simple AJAX is getting advanced
Posted in: Programming
In one of my previous posts – Simple AJAX example, I explained a few steps that will help you enter the web 2.0 development world using famous AJAX method.
In that example we were submiting a HTML form with POST method using XmlHttpRequest and then processing the request server-side using PHP and getting some results back to JavaScript, to the client machine without refreshing the whole page. Very cool :)
As you could see, the main part of code was to build a POST request, which in that example we we’re doing manually (var poststr in get function of JavaScript part). You can easily put more variables in that POST request, just append them into that string var and delimit them with &, just like a regular GET method.
But, what if we have much more variables to submit, and what if we would like to reuse JavaScript code for multiple forms on different pages?
Now it’s time to introduce you with – SACK – Simple AJAX Code-Kit, a PHP library that helps you coding AJAX applications.
Along with this library, here is the example on it’s usage, with downloadable files ready to play with – AJAX form submit.
-
-
var formObj = new DHTMLSuite.form({
-
formRef:‘myForm’,
-
action:‘includes/formSubmit.php’,
-
responseEl:‘formResponse’}
-
);
-
This JavaScript code should be added to your HTML form you’re trying to submit the AJAX way.
As you can see, it is very easy to use and is helping you with reducing the lines of code as well as reusing it.
Return to: Simple AJAX is getting advanced
Social Web