Skip to main content

Progress Button Using Ajax, Javascript And Jquery

Here i brought an all new tutorial to build a button with progress indication. It looks quite impressive and takes few lines of codes. We had used Ajax, Jquery and very important Javascript code. You just need to include "jquery.ajaxbuttonindicator.js" and  "jquery.min.js" files in the head section. They are script type.
A very important Ajax function is used in the whole code named ajaxbuttonindicator( );
All magic is performed in the Javascript. Only this Ajax function is called on the click of button. Value in the text-field goes to the php page and it return the string and displays on the HTML page.

Content Used :

  • Ajax
  • Javascript
  • Jquery  
  • A Simple Php Code 

    Javascript Code:

    $(document).ready(function() {
                $('button').ajaxbuttonindicator();
            });
            
            function send_request(a) {
                yourname = $('#i_name').val();
                $.post("backend.php", {name: yourname, action: a}, 
                    function(response) {
                        // Do something with the response.
                        $('#ajax_response').html(response.message);
                    }, 'json');
            }
     

    Before clicking:

     After Clicking:

    After Completion:

    PHP Code:


    200, 'message'=>'Success: '.$_POST['name'].''));
    			break;
    		case 'error':
    			header("HTTP/1.0 404 Not Found");
    			echo json_encode(array('code'=>200, 'message'=>'Error: '.$_POST['name'].''));
    			break;
    		default:
    			echo json_encode(array('code'=>200, 'message'=>'Default: '.$_POST['name'].''));
    	}
    	?>
    

    Note:

    If the timint between submition and completion is too fast put the time as per your requirment. Just as
    sleep(2); // 2 sec for completion the request.
    Please give your feedback for this post. Hope you will like it.
    
    

Comments

Popular posts from this blog

Eden: PHP Library To Get Things Easy For PHP Developer

Eden is PHP Library designed for helping developers in their rapid development work. In Our most of the project we have to integrate our developed website or application with most of  the social networking websites like Google, Facebook, Twitter, yahoo etc. so what we do is we integrate libraries of different websites differently Although We could make the code reusable but still if the websites increases then confusion will also increases. Adding different libraries form different sources add more complexity to your project and ends up to be hard to maintain. Eden simply a set of reusable components, that works with any PHP framework and CMS. Eden makes code logical and readable with dead simple syntax. Eden Will work With Most Of Web services including Amazon Web service Facebook Foursquare Google twitter tumbler Paypal Yahoo You could Download the File From  Eden Official Website  and Can use this will just a simply including this...

OSI Model (Tutorial-6)

What is the OSI model ? Open Systems Interconnection model is fundamental to all communications between network devices.  Developed in 1974 by ISO after the American Department of Defence began using the TCP/IP suite of protocols.  Finally adopted in 1977. It is now the theoretical model for how communication takes place between network devices. What are the seven layers ? Layers OSI Model Layer 7  Layer 6  Layer 5  Layer 4  Layer 3  Layer 2  Layer 1

CISCO System & Certifications

CISCO Systems Corporation: CISCO Systems is a large corporation that produces computer networking products and services. The Linksys brand of consumer networking products is also an owned subsidiary of CISCO Systems.