I need to add the data to the database and meanwhile load into a select options menu, I successfully added the data and when loading the data gets duplicated in the options menu
function manageRow(data) {
var rows = '';
$.each( data, function( i, o ) {
rows += '<option>'+o.salary_wage+'</option>';
});
$(".selectpicker111").append(rows);
}
Try this ;)
$("selector").append(rows);
This will append
options to existing options and you will get duplicate options.
There are 2 ways to get rid of duplicate options:
Option 1:
Remove existing options before adding options using empty and then you can add options using either append or html.
$("selector").empty();
Option 2:
Replace existing options with new options using html
$("selector").html(newOptions);
In your case:
$(".selectpicker111").html(rows);