Select Chapter ❯
jQuery Tutorial
- jQuery Introduction
- jQuery Selector
- jQuery Traversing
- jQuery Events
- jQuery Get/Set
- jQuery Add/Remove
- jQuery CSS
jQuery Effects
jQuery Ajax
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
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); }); });