I have a form with multiple dropdown
<select id="0" name ="0">
<option value="abc">ABC</option>
<option value="def">DEF</option>
.
.
.
<option value="mno">MNO</option>
</select>
.
.
.
<select id="9" name="9">
<option value="abc">ABC</option>
<option value="def">DEF</option>
.
.
.
<option value="mno">MNO</option>
</select>
// This is the basic structure of the code
Now I have a ajax call which gives the following json data
{"2":"abc","5":"def","6":"ghi","7":"def","4":"mno"}
I want to populate the dropdown as per the json data
eg for this case the dropdown with id 2 show have the option value as abc selected, the dropdown with od 5 should have its option with value as def selected and so on.
$.ajax({
type : 'POST',
url : ajax_url,
data : datavar,
success : function(msg) {
}
});
The json data is present in the msg parameter of success.
How should I proceed?