Thursday 25 October 2012

Ajax Library

Ajax is very important for websites development. It's work without refreshing the page of websites.

Following is given ajax function.

This will compatible with all browsers like opera, mozila firefox, chrome, IE7 and above.

just copy all code which is given in text area.

How to use this ajax is following. Follow step by step.


1. Copy all code from above text area and paste it on a page and save as ajax.js

2. Include this file on your page, where you want to ajax effect.

3. You can use this in js function as following.

      function checkEmail(email){
             var ajax = new Ajax();
             ajax.doGet('validateUser.php?checkUserEmail='+email,checkEmailNow,'text');
     } 


4. Now ajax is object and ajax.doGet means ajax call its doGet function.

5. validateUser.php is your page from where you need to get response.

6. Now checkUserEmail is request where we send user email .

7. checkEmailNow taking response from this page.

8.  Now how to use response, check following..

     var checkEmailNow = function(str){
             if(str == 0){
                   return false;
             }else{

                   return true;
             }
     }

9. This is ajax function and great function and compatible with all browsers.

10. This is javascript part so work carefully because single error create you problem.

No comments:

Post a Comment