<select id="multi-select-demo" multiple="multiple">
</select>
在下面的代码中,我们想通过ajax分配动态选项值,但是它不起作用
$.ajax({
type: 'POST',
url: 'get_checkparishdata',
data: { "campids": optionValue },
success: function (data2) {
new_data2 = data2;
if (new_data2 == '<option>No Record Found</option>') {
$(".bootparish").html(new_data2);
$("#multi-select-demo").html(new_data2);
$('#multi-select-demo').multiselect();
} else {
$(".bootparish").html(new_data2);
$("#multi-select-demo").html(new_data2);
}
}
});
//要分配动态选项值
$option_parish = '';
foreach($datapar as $Jurisdiction_parish)
{
$option_parish.='<option value="'.$Jurisdiction_parish.'"
selected>'.$Jurisdiction_parish.'</option>';
}
return $option_parish;