I have an ajax that return values from an another page, I want to target a value that matches from the value ajax returns and select it on the tag.
Here's my code so far:
success: function(data) {
$("select[name='account_type']").val(data.account_type).prop('selected', true);
},
I want to target this:
<select class="form-control">
<option value="0">DEBIT</option>
<option value="1">CREDIT</option>
</select>
So if the ajax call returns value of 1, then CREDIT should be :selected