I want to display data in select box option from ajax response.
here is my view file
<select class="form-control" name="vendor" id="vendor_list" required style="width: 159px;">
<option value="">Vendor 1</option>
</select>
Here is my ajax success function
success: function(data) {
$.each(data, function(i, value) {
console.log(value);
$('#vendor_list').append('<option value="'+ value.id+'">'+ value.vendor_name +'</option>');
console.log(value);
});
}
here is my ajax response json data
[{"vendor_name":"scscss"},{"vendor_name":"xzcdsfdx"}]
How to display value in select box. giv me suggestion.thanks
JSON.parse(data)morris.jswe don't even know what that is. I don't think we can help you with the shared code.