When I call a sync web service on my website, the results are not being waited for.
I am calling the function loadExtLayout within the loadLayout function, and then calling loadLayout in other functions on the website.
HTTPRequestService.prototype.loadExtLayout = function(pathToLoad){
logManager.IHM_LOG_INFO("BEGIN HTTPRequestService loadExtLayout call pathToLoad="+JSON.stringify(pathToLoad));
var loadResult = null;
$.ajax({
async:false,
method: "GET",
url: pathToLoad
}).done(function(result){
loadResult = result;
}).fail(function(jqXHR, textStatus){
loadResult = null;
logManager.IHM_LOG_ERROR(new Error().stack+": "+"Error loading layout : " + pathToLoad + " (" + textStatus + ")\n");
});
logManager.IHM_LOG_INFO("END HTTPRequestService loadExtLayout call");
return loadResult;
}
GenericLayoutController.prototype.loadLayout = function(layoutName){
logManager.IHM_LOG_INFO("BEGIN loadLayout");
var loadResult = false;
var layoutContent = null;
try {
var httpService = new HTTPRequestService(this.AppId);
if(httpService != null){
layoutContent = httpService.loadExtLayout(layoutName);
console.log("layoutContent :" + layoutContent);
if ((layoutContent != null) && ($("#window_"+ this.AppId + "_" + this.WndId).attr("patternname") == this.patternName)) {
$("#window_"+ this.AppId + "_" + this.WndId).empty();
$("#window_"+ this.AppId + "_" + this.WndId).html(layoutContent);
loadResult = true;
} else if( layoutContent == null ){
logManager.IHM_LOG_ERROR("Error loading layout !");
}
} else {
logManager.IHM_LOG_ERROR("Error unable to create HTTPRequestService object : httpService is null !");
}
} catch(e) {
loadResult = false;
logManager.IHM_LOG_ERROR(new Error().stack+": "+e+"\n");
}
logManager.IHM_LOG_INFO("END loadLayout");
return loadResult;
}