1
The AJAX call happens asynchronously, and only after it finishes it calls your callback function, which fills the select with options.
So the following happens: you start the AJAX call, then change the select’s value, then the AJAX call finishes, deletes all the options (including the selected one), and fills the select with new ones.
You should move section.val("1")
inside the callback function, just after the $.each
line.
Source:stackexchange.com