我想追加數據到選擇框。但是,我得到這個錯誤...問題在循環JSON
"Error: $("").attr("value", guruMapelId).html is not a function
Source File: http://localhost:8084/controller?aksi=kurikulum
Line: 5"
這是我的js代碼:
function dataGuruMapelSelect(dataSelect){
$.getJSON("controller", "aksi=dataGuruMapel", function(json){
$.each(json.guruMapelData, function(k,v){
var guruMapelId = v.guruMapelId;
var guruNama = v.guruNama ;
$('<option />').attr('value',guruMapelId).html(guruNama).appendTo(dataSelect);
})
});
}
這是JSON數據
{
"guruMapelData": [
{
"guruMapelId ": "1",
"guruNip ": "1331/001",
"guruNama ": "HARI BUDIYONO DRS.",
"mapelNama ": "PPKn",
"tahunAjarNama ": "2010/2011",
"mapelKategoriNama ": "Normatif",
"mapelId ": "1"
},
{
"guruMapelId ": "2",
"guruNip ": "1331/002",
"guruNama ": "PENI WARDAYANI DRA",
"mapelNama ": "Kewirausahaan",
"tahunAjarNama ": "2010/2011",
"mapelKategoriNama ": "Produktif",
"mapelId ": "2"
}
]
}
什麼是我的錯? 以前感謝...
謝謝...它的工作原理.... :D – rasyeda 2011-05-22 01:11:45