The problem you're facing is that you are calling
SetCollectionForDdl()
synchronously which means that this function returns as soon as it has exectuted. In function
SetCollectionForDdl()
you are the calling function
GetQualityTest()
also synchronously with the same implications as before: It returns immediately after it sent the
asynchronous AJAX call.
Since your AJAX call takes some time to complete the data has not been fetched yet. I suggest you try it like this:
$(document).ready(function () {
GetQualityTest();
});
function GetQualityTest() {
if (SET_QualityTestCollection.length == 0) {
$.post("/YS_PO/GetQualityTest", { },
function (data, textStatus) {
if (textStatus == "success") {
SET_QualityTestCollection = data;
doHTMLRenderingStuff();
}
},"json");
}
}
function doHTMLRenderingStuff()
{
}
Hope this helps you get the idea. I didn't want to refactor the two functions for you as I think you'd be better at doing that :). I just needed to point out that mixing asynchronous calls with synchronous calls doesn't yield the expected results.
Best Regards,
Manred