196
rated 0 times
[
200]
[
4]
/ answers: 1 / hits: 30279
/ 9 Years ago, thu, september 24, 2015, 12:00:00
I have use chosen at http://harvesthq.github.io/chosen/ . Ok, i testing it load data from ajax . I founding anywhere, maybe no someone success with them.
<script src=theme/js/jQuery-2.1.3.min.js></script>
<link href=theme/chosen_v1.4.2/chosen.css rel=stylesheet />
<script src=theme/chosen_v1.4.2/chosen.jquery.js></script>
<script type=text/javascript charset=utf-8>
$(document).ready(function () {
$(.cb_bu_info).chosen({
width: 95%,
source: function (data) {
$.ajax({
type: POST,
url: ../BUS/WebService.asmx/LIST_BU,
contentType: application/json; charset=utf-8,
dataType: json,
success: function (data) {
$(#cb_info).html('');
//$.each($.parseJSON(data.d), function (idx, obj) {
$.each(data, function (idx, obj) {
$(#cb_info).append('<option value=' + obj.BU_ID + '>' + obj.BU_NAME + '</option>');
});
//$(#cb_info).trigger(liszt:updated);
},
error: function (data) {
console.log(data.d);
}
});
}
});
$(#cb_info).trigger(liszt:updated);
});
</script>
<select id=cb_info class=cb_bu_info></select>
The data form ajax as
[{BU_ID:B01,BU_NAME:Agro Feed,BU_DES:Agro Feed,EDIT_DATE:2015-05-05T00:00:00,EDIT_BY:,FLAG:false},{BU_ID:B02,BU_NAME:Agro Farm,BU_DES:Agro Farm,EDIT_DATE:2015-05-05T00:00:00,EDIT_BY:,FLAG:false}]
Well , it's look ok , but when i run it , result not show in select option, see browser dev tool , I've not seen error. Anything is ok.What's the problem happen in here? Notes: only use Chosen Jquery
More From » jquery