I have a jquery postback and after getting reply as JSON I'm changing value of an input type select like this
$('#new-address select[name=\'country_id\']').val(data['country_id']).trigger('change');
$('#new-address select[name=\'zone_id\']').val(data['zone_id']);
and after changing the selected value I am firing an event 'change' to fill state select input and after that I want to change the selected value of state select input but from above code it's not changing the value of state select but it's filling states.
So I thought may be control is not coming back after trigger to this function so to test that I put one alert to see whether it's coming here or not like this
$('#new-address select[name=\'country_id\']').val(data['country_id']).trigger('change');
alert('came here');
$('#new-address select[name=\'zone_id\']').val(data['zone_id']);
after testing this I got alert saying came here and after clicking OK, the value of state is changing as I wanted.
So what is wrong in my approach before and why it's working fine after adding alert? What changes should I do to get what I want?
Thanks in advance.