I'm new to jQuery and looking for some advice. I'm loading data into a number of select boxes. The data of each select box is loaded dependent on the selection of the previous. What I was experiencing was that sometimes the data would be slow to come through and the select box would be loaded without being populated with data. I got around this by adding an async:false parameter. I believe this is bad practice though? What is the alternative approach to using async false?
$.ajax({
async: false,
type: "POST",
dataType: "xml",
url: "/data.asmx/GetModels",
data: "make=" + make + "",
success: function (response) {
$(ddlModel).attr('disabled', false).removeOption(/./).addOption('', ' -- Select Model -- ');
$(response).find('string').each(function () {
if ($(this).text() == selectedItem)
{
$(ddlModel).addOption($(this).text(), $(this).text(), true);
} else {
$(ddlModel).addOption($(this).text(), $(this).text(), false);
}
});
}
});