以下是 HttpMapRoute "serviceUrl.
<ArrayOfProject>
<Project>
<AssignedUserId>5</AssignedUserId>
<CreatedByUserId>1</CreatedByUserId>
<CreatedOnDate>2013-08-15T01:18:37.443</CreatedOnDate>
<LastModifiedByUserId>1</LastModifiedByUserId>
<LastModifiedOnDate>2013-08-15T01:24:57.953</LastModifiedOnDate>
<ProjectDescription>Testing javascript and MVVM with DNN-platform
</ProjectDescription>
<ProjectId>1</ProjectId>
<ProjectName>javascript and DNN</ProjectName>
<Purpose>For fun</Purpose>
</Project>
<Project>
<AssignedUserId>5</AssignedUserId>
<CreatedByUserId>1</CreatedByUserId>
<CreatedOnDate>2013-08-15T01:18:37.443</CreatedOnDate>
<LastModifiedByUserId>1</LastModifiedByUserId>
<LastModifiedOnDate>2013-08-15T01:27:57.419</LastModifiedOnDate>
<ProjectDescription>DNN Module design in development and Skins
</ProjectDescription>
<ProjectId>2</ProjectId>
<ProjectName>CSS systems in DNN</ProjectName>
</Project>
</ArrayOfProject>
我的 JSON 调用如下:
self.projectCollection = ko.observableArray([]);
$.getJSON(serviceUrl, function (allData) {
var i = 0;
$.each(allData, self.projectCollection.push(new Project(allData[i++])));
});
... 其中 Project 是一个函数:
function Project(data) {
var self = this;
self.projectname = ko.observable(data.ProjectName);
self.description = ko.observable(data.ProjectDescription);
self.assigneduserid = ko.observable(data.AssignedUserId);
self.createdondate = ko.observable(data.CreatedOnDate);
self.createdbyuserid = ko.observable(data.CreatedByUserId);
self.lastmodifiedondate = ko.observable(data.LastModifiedOnDate);
self.lastmodifiedbyuserid = ko.observable(data.LastModifiedByUserId);
}
为什么我的“projectColletion”没有比第一个 Project 填充更多?