facebook模块,获取数据时出错
facebook module, buggy when fetching data?
这是我的异步方法:
function getAlbumCovers() {
//first check to see if profile pics already exist in user model
//create a collection
var usersCollection = Alloy.Collections.user;
facebookModule.requestWithGraphPath('me/albums', {
fields : 'id,name,cover_photo,count,created_time'
}, 'GET', function(graphResp) {
//show view indicator before data is fetched
$.view_indicator.visible = true;
if (graphResp.success) {
if (graphResp.result) {
var rows = [];
var data = JSON.parse(graphResp.result).data;
var i=0;
for (x in data) {
Ti.API.debug(JSON.stringify(data[x]));
var Albums = String.format("%s (%d)", data[x].name, data[x].count);
console.log(Albums);
var row = Titanium.UI.createTableViewRow({
width : '100%',
height : 'auto'
});
var image = Titanium.UI.createImageView({
image : "https://graph.facebook.com/" + (data[x].cover_photo || 0) + "/picture?access_token=" + Ti.Facebook.accessToken,
top : 0,
left : 0,
width : 100,
height : 100
});
var title = Titanium.UI.createLabel({
text : test,
top : 0,
left : 110,
width : 'auto',
height : 'auto'
});
row.add(image);
row.add(title);
rows.push(row);
}
console.log(rows);
//set table rows
$.tableview.setData(rows);
//end
$.view_indicator.visible = false;
}
} else {
if (e.error) {
alert(e.error);
} else {
alert("Unkown result");
}
}
});
}
问题是,以下是我对console.log(rows);
的输出(如果我一直关闭并重新打开窗口(:
[INFO] : Profile Pictures (4)
[INFO] : Cover Photos (1)
[INFO] : Mobile Uploads (0)
[INFO] : Timeline Photos (0)
[INFO] : Untitled Album (0)
[INFO] : Untitled Album (1)
// Fine
[INFO] : Profile Pictures (4)
[INFO] : Cover Photos (1)
[INFO] : Mobile Uploads (0)
[INFO] : Timeline Photos (0)
[INFO] : Untitled Album (0)
[INFO] : Untitled Album (1)
// Fine again
[INFO] : Profile Pictures (4)
[INFO] : Cover Photos (1)
[INFO] : Mobile Uploads (0)
[INFO] : Timeline Photos (0)
[INFO] : Untitled Album (90668843350925705704470860216788845156409915121482525099460797528722583431186535307341891426094773480786356228821741890211882156053220804540899892654174105362205327540955324744929635810063978450130488142173895865528091904584042889722878136145298291869241384290654277861376)
[INFO] : Untitled Album (1)
// Bug
[INFO] : Untitled Album (1)
[INFO] : Profile Pictures (4)
[INFO] : Cover Photos (1)
[INFO] : Mobile Uploads (0)
[INFO] : Timeline Photos (0)
[INFO] : Untitled Album (0)
// Fine
有时这行代码会随机失败,结果是:
var Albums = String.format("%s (%d)", data[x].name, data[x].count);
我不知道为什么会发生这种情况,也不知道为什么表上的数据表现不稳定。任何想法,干杯。
String.format("%s (%d)", data[x].name, data[x].count);
这就是导致错误的原因。您可以通过将两个不同的字符串连接在一起进行更正,一个用于计数,另一个用于名称
相关文章:
- 将图像下载为数据url时出错
- 使用Angular获取数据API调用时出错
- 解析将数据从 JSON 发送到 Django 时出错
- 尝试在移动优先应用程序中从 SQL 数据库获取数据时出错
- Node.js错误:参数太多上传批量数据时出错
- 访问console.log中的数据属性时出错
- 将数据插入数据库express/mongodb应用程序时出错
- 在javascript中替换当前数据时出错
- 从Node.js在Neo4j中引入大量数据时出错
- 在NodeJS中编辑JSON数据时出错
- 使用ajax将数据发布到asmx web服务并使用javascript函数在html页面中编写响应时出错
- Javascript uncatch Referenceerror,从 localStorage 检索数据时出错
- 将数据从 ASP.Net 4.5 发布到 ASP.Net 2.0 Web 应用程序时出错
- 在我的 Rails 应用程序中使用 jQuery 数据表时出错
- 在变量中存储 JSON 数据时出错
- 使用 Mongoose 和 Node 将数据插入数组时出错
- 将数据从异步请求添加到 WebSQL 数据库时出错
- 数据表 YADCF 重置所有列时出错(exResetAllFilters)
- SAP openui5:将自定义数据附加到表列模板时出错
- PHP 和 AJAX 在接收数据时出错