Select box

hello Stanislav
i have a custom form to show up in the lightbox. I have select dropdown box usinga DIV.The options in this select box are retrieved from DB by making a AJAX call.This ajax call makes a request and waits for the response.Here this is a wait period and the lightbox will not wait and will show up without the options inthe select box and sometimes even the lightbox doesnt show up and throws a error saying the data required is not yet available.So the workaround for this is When it make this request i have to put a alert message box to cover up for the delay which shows up in the browser and the user just clicks ok and then the option in the select box show up in the lightbox.How do we achieve this without using the alert message box to cover up for the delay .I am not sure if this is right way to do it. Please advise

scheduler.form_blocks[“my_editor”]={

render:function(sns){
var xhtml=showoptions();

//xhtml will have the options for the select box
//construct the DIV using the select box after getting the response from ajax call
return

+xhtml+

},
}

function showoptions()
{

xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
var url="MakeBellAjax.jsp?";

xmlHttp.open("GET",url,true);
xmlHttp.send(null);
xmlHttp.onreadystatechange=stateChanged;
// waits here for the response before the result can be returned

alert(“processing request”); /// This is used to cover up for the delay so the response is built and sent to the calling function
return xmlHttp.responseText;

}

function stateChanged()
{
var result;
if (xmlHttp.readyState==4)
{
result= xmlHttp.responseText;

}

}

Why not call showoptions() during initial scheduler rendering, so at moment when lightbox will be opened, they will be loaded for sure?

You have two solutions
a) you can change you ajax operation to sync. one - so it will stop any code while data is not loaded
b) you can

  • return false from onBeforeLightbox event to prevent lightbox opening
  • call showoptions
  • when options loaded - call scheduler.showLightbox to show lightbox ( now , when options are loaded )

Why not call showoptions() during initial scheduler rendering, so at moment when lightbox will be opened, they will be loaded for sure?

You have two solutions
a) you can change you ajax operation to sync. one - so it will stop any code while data is not loaded – Can you please explain with steps with the above code ?
b) you can

  • return false from onBeforeLightbox event to prevent lightbox opening
  • call showoptions
  • when options loaded - call scheduler.showLightbox to show lightbox ( now , when options are loaded ) — Please explain with steps with the above code