I have the following code:
AJAX:
function GetLoggedInUserName() {
var username = null;
$.ajax({
url: 'Login.aspx/GetLoggedInUserName',
type: 'POST',
contentType: 'application/json; charset=utf-8',
async: false,
dataType: "json",
data: '{ }',
success: function(Result) {
if (Result != "") {
var ClientResponse = JSON.parse(Result.d);
alert("res: " + ClientResponse.Success);
alert("data:" + ClientResponse.Data);
if (ClientResponse.Success) {
username = ClientResponse.Data;
}
else {
showDialog('indicator', {
message: ClientResponse.Message,
type: 'error'
}, false);
}
}
},
error: function(xhr, textStatus, errorThrown) {
showDialog('indicator', {
message: 'An error occured in GetLoggedInUserName',
type: 'error'
}, false);
}
});
return username;
}
Use:
var loggedInUser = GetLoggedInUserName();
alert(loggedInUser);
when I run this code on PC, everything is working fine. when I ran this code on IPAD (safari/chrome) then I get "null" in the alert, and then I get the alerts I have inside the ajax call:
alert("res: " + ClientResponse.Success);
alert("data:" + ClientResponse.Data);
So I suppose that async: false doesn't really works on IPAD. Is it true? Is there any way to use synchronous ajax calls on IPAD?