$,ajax() allows to make an ajax call.
This method provide more control than any other method.
In the ex below all the parameters and comment related to each parameter describe the purpose of each one.
var ajaxUrl = "Json.htm";
$("#btnAjax").click(function () {
$("#dvAjax").html(ajax_load);
$.ajax({
type: "GET", //GET or POST or PUT or DELETE verb
url: ajaxUrl, // Location of the service
data: "", //Data sent to server
contentType: "", // content type sent to server
dataType: "json", //Expected data format from server
processdata: true, //True or False
success: function (json) {//On Successful service call
var result = json.name;
$("#dvAjax").html(result);
},
error: ServiceFailed // When Service call fails
});
return false;
});
Important
It provide more control on data sending and response.
It allows to handle error occur during call.
It allows to handle data if the call to the page is successful.
0 Comment(s)