It works fine when I modify the code as follows
function UserAuthorityCheck(){
var bool = false;
$.ajax({
async: false,
type: "POST",
url: "http://localhost:80/myApp/MyWebService.asmx" + "/" + "MyUserInRole",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data.d == 'success') {
bool = true;
}
else {
bool = false;
}
},
error: function (data) {
bool = false;
},
timeout: 20000
});
return bool;
}
$(document).ready(function () {
var response = UserAuthorityCheck();
if (response != undefined || response != null) {
isUserAuthority(response);
}
function isUserAuthority(response) {
if (response == true) {
var element = $(document).find('input#btnsearch');
element.prop('disabled', false);
}
else {
var element = $(document).find('input#btnsearch');
element.prop('disabled', true);
}
}
});