【发布时间】:2015-12-14 02:57:02
【问题描述】:
我使用了从
中选择的 jqueryhttps://github.com/harvesthq/chosen/releases
我从 ajax webservices 绑定数据,似乎它不起作用。数据未在选择中加载。
$(".cb_bu_info").chosen({
no_results_text: "Oops, nothing found!",
width: "50%",
source: function () {
$.ajax({
type: "POST",
url: "../BUS/WebService.asmx/LIST_BU",
contentType: "application/json; charset=utf-8",
dataType: "json",
//beforeSend: function () { $('ul.cb_bu_info').empty(); },
success: function (data) {
$("#cb_bu_info").html('');
$.each($.parseJSON(data.d), function (idx, obj) {
$("#cb_bu_info").append('<option value="' + obj.BU_ID + '">' + obj.BU_NAME + '</option>');
});
},
error: function (data) {
console.log(data.d);
alert("An error occurred !");
}
});
}
});
<select class="cb_bu_info"></select>
谢谢大家。
【问题讨论】:
-
你没有包含 jquery 脚本?
-
jquery 和另一个我与 $ 冲突?
-
亲爱的@Pekka,是的,我用过 jquery。
标签: jquery ajax html select jquery-chosen