Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery Misc get() Method

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 47
    Comment on it

    Hello Readers,


    Here we are talking about jquery get() method in this post. It load data from the server using a HTTP GET request. It Send an HTTP GET request to a page and get a response.


    Syntax: $.get( url, [data], [callback], [type] )
    


    Parameters:

    url: This is a string that containing a URL to which the request is sent.

    data: It is the optional parameter which represents key/value pairs which.

    callback: It is the optional parameter which represents a function to be executed whenever the data is loaded successfully.

    type: This is the optional parameter which represents type of data to be returned to callback function: "html", "xml" "script", "jsonp", "json" or "text".


    Example:

    <html>
    <head>
    <title>The jQuery get() method example</title>
    <script type="text/javascript" src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function() {
        $("#driver").click(function(event){
            $.get( "process.php",{ name: "Evon" },
    
            function(data) {
                $('#stage').php(data);
            });
        });
    
    });
    </script>    
    </head>
    
    <body>
    <p>Click on the button to load process.php file </p>
    <span id = "stage" style = "background-color:#c00;">STAGE</span>
    <div><input type = "button" id = "driver" 
    value = "Load Data" /></div>
    </body>    
    </html>
    


    The above following example call to "process.php" so that we need to create process.php page where we can define internal and get result.


    following example shows the process.php page.

    <?php
    if( $_REQUEST["name"] ) {
    
       $name = $_REQUEST['name'];
       echo "Welcome in ". $name;
    }
    
    ?>
    


    Thanks


 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: