You're making an asynchronous http request, so your buildDropDown
method gets called too early. You could try setting an ajax option to make it a synchronous request.
$.ajax({
async: false, // yay for sync
url: 'formdata/crooms.xml',
dataType: 'xml',
success: function (xmlData) {
directoryObj.formData = xmlData;
}
});
Alternatively you could just call buildDropDown
inside of your success handler.
$.ajax({
url: 'formdata/crooms.xml',
dataType: 'xml',
success: function(xmlData) {
directoryObj.formData = xmlData;
directoryObj.buildDropDown();
}
});