I think you are looking for something like this:
$.ajax({
type: "POST",
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
url: "",
data: "",
success: function (r) {
},
beforeSend: function (XMLHttpRequest) {
$.mobile.showPageLoadingMsg();
},
complete: function (XMLHttpRequest, textStatus) {
$.mobile.hidePageLoadingMsg();
},
error: function (xmlHttpRequest, status, err) {
$.mobile.hidePageLoadingMsg();
}