我建立了处理网页的原型,我成功地增加了(粉碎),但能够获取数据,我失败:
var foundImageIndex = Pages.indexFirst(function (item) { if (item.PageID == PageID) return true; });
The javascript pagehandler:
var Pages = new Array();
PageContainer = function () //constructor for the proxy
{
// this._baseURL = url;
};
PageContainer.prototype =
{
AddPage: function (data) {
if (data == null) return;
Pages.push({ PageID: data.PageID, SegmentID: data.SegmentID });
},
GetPage: function (PageID) {
alert( getPage( +PageID+ )= + JSON.stringify(Pages));
var foundImageIndex = Pages.indexFirst(function (item) { if (item.PageID == PageID) return true; });
var dt = { PageID: Pages[foundImageIndex].PageID, SegmentID: Pages[foundImageIndex].SegmentID };
return dt;
}
};
我呼吁其他各位:
var gPageContainer = new PageContainer();
for (var i = 0; i < SegStruct.SegmentsCount; i++) {
var segRClass = //get from webservice
gPageContainer.AddPage({ PageID: i, SegmentID: segRClass.SegmentID });
}
I trying to call: gPageContainer.GetPage(1); but it failed in GetPage: function (PageID) it returns -1 in: var foundImageIndex = Pages.indexFirst(function (item) { if (item.PageID == PageID) return true; });
发现 图Index一贯-1
为什么?