我有这个功能
function getAllDays(year,month){
var getdate = new Date(); //Used to prevent caching during ajax call
$.getJSON("AantalUrenAjax?_d" +(new Date().getTime()) +"&jaar=" + year + "&maand=" + month ,function(data)
{
$.each(data, function(index, value)
{
windows.alert(('#Dag').val(value.Maand));
});
});
ajax调用给我的JSON是:
[{"Dag":"2013","Maand":"10","Jaar":"01","aantalafspraken":0},
{"Dag":"2013","Maand":"10","Jaar":"02","aantalafspraken":0},
{"Dag":"2013","Maand":"10","Jaar":"03","aantalafspraken":0},
]
如何获取值?
windows.alert(('#Dag').val(value.Maand));
崩溃:(
最佳答案
您的代码中有一些语法错误。函数顶部有一个流浪v
,windows.alert
应该为window.alert
。您在jQuery调用前缺少$
。您还会警告jQuery对象,您正在将值设置为该值,而不是值本身。您可能想要:
window.alert(value.Maand);
$('#Dag').val(value.Maand);