Join TalkersCode Now !

Get Latest Tutorials And Links On Web Development
And Get Existing Offers Via Email

jQuery Ajax Get and Post

jQuery Ajax Get and Post

With the help of jQuery Ajax Get and Post you can request data to the server without page refresh using HTTP GET or POST request.


Difference Between GET and POST request

  • GET:is used to request data from the server or any source
  • POST:is used to submit data to the server or any source

  • jQuery GET Method

    jQuery GET Method is used to get data from the server or any specified source


    Syntax

    $.get(URL,callback);


    Code Explanation

    • URL is used to set the URL from which you can get the data
    • callback is used to set the function that is executed after request success

    Example of GET Method

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



    jQuery POST Method

    jQuery POST Method is used to send data to the server or any specified source


    Syntax

    $.post(URL,data,callback);


    Code Explanation

    • URL is used to set the URL from which you can get the data
    • data is the data used to send to the server or the source specified in the URL parameter
    • callback is used to set the function that is executed after request success

    Example of GET Method

    $("button").click(function(){
    $.post("demo.asp",
    {
        name:"Rokit",
        city:"MBA",
        RollNo:"3435"
    },
    function(data,status){
        alert("Data: " + data + "\nStatus: " + status);
      });
    });
    
    Previous

    Join Us With Our 21000+ Subscribers And Get Our Latest Tutorials Update Via Email

    Are You Starting A New Blog
    Do You Want Best Web Hosting?

    Try World's Best Web Hosting Provider BlueHost
    At Just $3.95/mo

    Hurry Up! Limited Time Offer

    Yes, I Want To Check Out BlueHost

    Check The World's Best SEO And All-In-One Marketing Toolkit
    For Digital Marketing Professionals SEMRUSH

    Check Out SEMRUSH