• Thursday, February 27, 2014

    JQuery $.get function - jquery to load data from the server using HTTP GET

    GET is basically used for getting your data from the server.
    jQuery $.get() function request data from the server using HTTP GET.

    Syntax: $.get(url,CallBack);

    url: A string contains the url, to which request is send.

    CallBack: a function which execute when the request succeeds.

    Example:



    $.get("\a.php?id=test",function(data)
    {
    alert("Success. Data: " + data);
    });

    Full Example:
    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
    </script>
    <script>
    $(document).ready(function(){
      $("#btn").click(function(){
       $("#result").html("Please Wait.............");
       $.get("/test.php",function(data){
        $("#result").html(data);

       });
      });
    });
    </script>
    </head>
    <body>
    <div id="result"></div>
    <br />
    <input type="button" id="btn" value="Click Me" />
    </body>
    </html>

    Syed Masoom Rizvi

    Author & Editor

    Hi, This is Syed Masoom Rizvi, who is continue exploring the world of programming ,programming and programming... :)

    0 comments:

    Post a Comment