Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • HTTP request get vs post in jQuery AJAX

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 240
    Comment on it

    Client and server communication is done with two commonly used http method

    1.GET

    2.POST

    GET- GET is basically used for getting the data from the server sometime cached.

    The $.get method is used in jQuery to get the data.

    $.get(URL,callback);

    url spicifies the url you wish to request.

    callback function is the name of the function you want to call the executed code.

    ex

    $("button").click(function(){
        $.get("demo_test.asp", function(data, status){
            alert("Data: " + data + "\nStatus: " + status);
        });
    });

    POST- POST is also used for the same but it never cached the data and used to send the data with the request.

    $.post() is the method for getting data in jQuery.

    $.post(URL,data,callback);

    url is the parameter you want to request.

    data is the data that can be send with the request.

    callback is the function can be called after the executed code.

    ex

    $("button").click(function(){
        $.post("demo_test_post.asp",
        {
            name: "Donald Duck",
            city: "Duckburg"
        },
        function(data, status){
            alert("Data: " + data + "\nStatus: " + status);
        });
    });

     

 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: