0
我通過循環該列表生成jQuery的字符串如下如何在ASP.net中使用for循環生成字符串?
events: [
{
title: 'All Day Event',
start: '2014-11-01'
},
{
title: 'Long Event',
start: '2014-11-07',
end: '2014-11-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-11-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2014-11-16T16:00:00'
},
{
title: 'Conference',
start: '2014-11-11',
end: '2014-11-13'
},
{
title: 'Meeting',
start: '2014-11-12T10:30:00',
end: '2014-11-12T12:30:00'
},
{
title: 'Lunch',
start: '2014-11-12T12:00:00'
},
{
title: 'Meeting',
start: '2014-11-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2014-11-12T17:30:00'
}
]
列表包含這些元素,但我無法產生這種字符串的.I've試圖以兩種方式
for(var i=0; i<customers.length; i++)
{
"{"
"title:" +customers[i].Column1+","
"start:"+customers[i].Column3
"}"
if(i!=customers.length-1)
{
","
}
}
和
$.each(eventList, function (index, employee) {
{
title:employee.name,
start:employee.date
}
,
});
,但我無法得到正確的結果,請給我解決這個。要獲取列表我使用下面的COE
$(document).ready(function() {
$.ajax({
type: 'POST',
dataType: 'json',
contentType: 'application/json',
url: 'ProjectedYieldCalender.aspx/GetData',
data: '{}',
success:
function (data) {
var eventList = data.d
eventList=demo(eventList);
initCalendar(eventList);
}
});
});
function initCalendar(eventList) {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
//defaultDate: '2014-08-12',
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
eventList
]
});
}
謝謝
似乎你患上了一廂情願的想法。請看MDN如何將內容分配給變量 – mplungjan
「ProjectedYieldCalender.aspx/GetData」頁面是否返回json數據? – ismailperim