According to need,
function GetCurrentUser() {
$.ajax({
type: "POST",
url: "TestService.asmx/GetCurrentUser",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: onSuccessGetCurrentUser,
error: onError,
beforeSend: startingAjax,
complete: ajaxCompleted,
cache: false
});
}
function onSuccessGetCurrentUser(data, status) {
if (data.d != "") {
alert('Employee id: ' + data.d);
}
}
function onError(request, status, error) {
var msg = 'Error occoured';
alert('Error: ' + msg);
}
function startingAjax() {
$('#imgLoading').show();
}
function ajaxCompleted() {
$('#imgLoading').hide();
}
Where beforeSend is the function to show gif image and complete is the function when your data return in json format.
No comments:
Post a Comment