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)