I got stuck finding the issue in my code below:
function fillStateList(cid) {
$.ajax(
{
type: "POST",
contentType: "application/json; charset=utf-8",
url: someurl,
data: "{'countyId': '" + cid + "'}",
dataType: "json",
success: function (data) {
if (data.d.length > 0) {
//alert('r- ' + stateId); // <-- if uncomment this line, the code works fine !
// code to bind select list
}
}
});
}
I am calling fillStateList
4 times sequentially to bind 4 different select list but sometimes its working and sometimes not!
But if I uncomment alert('r- ' + stateId)
to make sure the success events calling for each request, its working fine (i.e. all select lists successfully binding!)
Also tried: async: false