I have a function which draws different popups depending on the value of my monitor type. If my monitorType = 22
I need to send an ajax request and depending on the response continue the drawing. But the problem is that I cant get response before to continue.
Here is that part of my function:
var str = '<div id="thresholdsHeader" style="display:none;">';
str += '<div id="alertRule"></div>';
if(monitorTypeId == 22 ){
var parametrs = {
monitorId: module.info.id,
typeId: module.info.monitorTypeId
};
sendGetAPIRequest(Framework.customMonitorURL, "getMonitorDynamicMetrics", parametrs, ThresholdManager.getDynamicThresholdsRequest);
if(dynResponse.json.length == 0){
str += '<input type="button" designstyle="green" onclick="ThresholdManager.addThresholdDialog()" style="float:right;" value="'+Framework.Lang.addThreshold+'"/>';
}else{
str += '<input type="button" id="trehsoldsGreenBut" designstyle="green" onclick="ThresholdManager.createThresholds(event)" style="float:right;" value="'+Framework.Lang.addThreshold+'"/><div class="dashboardIcons addNewRuleArrow" style="left: '+(CURRENT_LANGUAGE == 'en'? '460':(CURRENT_LANGUAGE == 'de'?'363':'355'))+'px;top: 8px;"></div>';
}
}else {
str += '<input type="button" designstyle="green" onclick="ThresholdManager.addThresholdDialog()" style="float:right;" value="'+Framework.Lang.addThreshold+'"/>';
}
str += '</div><div id="thresholdContainer"></div>';
and this is my request handler :
getDynamicThresholdsRequest: function(response){
dynResponse = response;
},
if I go slow by debugging it works ok.