【发布时间】:2018-06-29 06:42:57
【问题描述】:
function getNamefromDb(){
var dataString = "metodo=getNames";
$.ajax({
type : "GET",
url : "NameList.do",
data : dataString,
dataType: "json",
async: false,
contentType: "application/json; charset=utf-8",
success : function(data) {
if (data.success == false) {
swal({
title: data.message,
html: true,
});
console.log("Fail"+data.message);
} else {
console.log("Success");
$.each(JSON.parse(data.message), function(key, value) {
$('#selectBoxId').append($("<option/>", {
value: key,
text: value
}));
});
$("#selectBoxId").multiselect('rebuild');
}
}
});
}
<select id="selectBoxId" multiple="multiple" onclick="javascript:getNamefromDb();">
【问题讨论】:
标签: javascript ajax multi-select