I got some trouble with select2 ajax script, My unique_ID in table field is called "no", so I Unable to select an item in Select2 drop down. When I changed my database table field "no_donatur" into "ID" my ajax select2 is working..
here is my function script :
$('.muzakki').select2({
placeholder: '--- Select Item ---',
ajax: {
url: '<?php echo site_url("transaksi/penerimaan_ajax") ?>',
dataType: 'json',
delay: 250,
cache: true,
minimumInputLength: 2,
processResults: function (data) {
return {
results: data
};
}
}
});
And also here is some json output :
[{"no":"4150","text":"NASIKIN (SMP N 2 MANYARAN)"},{"no":"5818","text":"Winasih (Via Asgim)"},{"no":"7499","text":"Tri winasih (Via Yeti)"},{"no":"9206","text":"RINASIH (RS ORTHOPEDI)"},{"no":"11673","text":"SHOLEH (NASI KABULI)"},{"no":"12818","text":"ININGSIH (BADAN PERTAHANAN NASIONAL)"},{"no":"20504","text":"NASITA GAIDA MUTIE (MOJOLABAN)"},{"no":"23656","text":"NASIR (PUSK NGAWEN)"},{"no":"26520","text":"RISMA AZIL NASIFA "},{"no":"26549","text":"SRI KARNASI"}]
How can I change "no" into ID without changing my database structure ?
solved by renaming no as id in my model..
thanks
请在模型中完成它,
SELECT no AS ID,....,.. FROM table_name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.