Ajax Request Response
AJAX (Asynchronous Javascript and XML)
This is a client side script that use to get and pass data from and to the server or database without completely refreshing or without any post back. Mainly use to update a web page partially.
simple ajax request/response
$.ajax({
type:'GET', //this specifies the type of the request. ex:- GET , POST
url:'getDataFromThisURL.php', //this specifies the url which should be redirect when the ajax //response executes
data:{key:value}, //this is optional. if we have to pass any data(ex:-form data) then we should pass //that data like this. in here KEY is the variable which will pass with the request //and the VALUE is
//the value we want to assign to that KEY variable and pass with the request
success:function(responseData){ //success - this is the block where ajax caught the positive response.
//(if there is no errors)
//manipulate the response data
},
error:function(xhr,status,error){
//this is where ajax caught any errors occur while the ajax request executes
}
});
This is a client side script that use to get and pass data from and to the server or database without completely refreshing or without any post back. Mainly use to update a web page partially.
simple ajax request/response
$.ajax({
type:'GET', //this specifies the type of the request. ex:- GET , POST
url:'getDataFromThisURL.php', //this specifies the url which should be redirect when the ajax //response executes
data:{key:value}, //this is optional. if we have to pass any data(ex:-form data) then we should pass //that data like this. in here KEY is the variable which will pass with the request //and the VALUE is
//the value we want to assign to that KEY variable and pass with the request
success:function(responseData){ //success - this is the block where ajax caught the positive response.
//(if there is no errors)
//manipulate the response data
},
error:function(xhr,status,error){
//this is where ajax caught any errors occur while the ajax request executes
}
});
Comments
Post a Comment