查询返回控制台日志中的项目,但是html显示Uncaught TypeError: Cannot call method
Query returns items in console log, but html is showing Uncaught TypeError: Cannot call method 'get' of undefined when trying to display on the page
Parse.com和JavaScript SDK。
代码查询并返回结果,然后应该显示在id "imgs"中。现在我得到一个
Uncaught TypeError: Cannot call method 'get' of undefined
错误。我试过了,但不明白是什么原因造成的或如何解决它。
页面的url在这里http://kudosoo.com/friendslistTEST.html
把我逼疯了
var currentUser = Parse.User.current();
var FriendRequest = Parse.Object.extend("FriendRequest");
var query = new Parse.Query(FriendRequest);
query.include('toUser');
// query.include('fromUser');
//query.include('pic');
query.equalTo("fromUser", currentUser);
query.equalTo("status", "Request sent");
query.find({
success: function(results) {
// If the query is successful, store each image URL in an array of image URL's
imageURLs = [];
for (var i = 0; i < results.length; i++) {
var object = results[i];
imageURLs.push(object.get('pic'));
}
// If the imageURLs array has items in it, set the src of an IMG element to the first URL in the array
for(var j = 0; j < imageURLs.length; j++){
$('#imgs').append("<img src='" + imageURLs[j].get("toUser").pic + "'/>");
}
},
error: function(error) {
// If the query is unsuccessful, report any errors
alert("Error: " + error.code + " " + error.message);
}
});
// show the signup or login page
</script>
<div id="imgs"></div>
使用。
imageURLs = [];
for (var i = 0; i < results.length; i++) {
var object = results[i].get("toUser");
imageURLs.push(object.get("pic"));
}
// If the imageURLs array has items in it, set the src of an IMG element to the first URL in the array
console.log(imageURLs);
for(var j = 0; j < imageURLs.length; j++){
$('#imgs').append("<img src='" + imageURLs[j] + "'/>");
}
相关文章:
- 扩展SVGTextElement时出现Typescript Uncaught TypeError
- Uncaught TypeError:undefined不是函数-ember js
- Snap()方法导致Uncaught TypeError
- 尝试使用.ninnerHTMLlog打印数据,获取错误Uncaught TypeError:undefined不是函数
- Android/Javascript:Uncaught TypeError Object[Object]没有方法'
- Reactjs错误:babel runtime.js:32 Uncaught TypeError:超级表达式必须为nul
- Jquery,Uncaught TypeError:undefined不是函数
- JavaScript uncaught Typeerror
- Uncaught TypeError:$(..).find(..).oonce不是bootstrap/js/bootst
- jQuery-Uncaught TypeError:$不是函数
- Uncaught TypeError:对象原型在Symfony 2中只能是Object或ExtJS为null
- jQuery令牌输入轨道获取错误Uncaught TypeError:Object[Object Object]没有方法
- 在Meteor中使用fs模块获取Uncaught TypeError _fs2.default.readFile不是函数
- 用谷歌闭包编译器编译jQuery会产生Uncaught TypeError
- 正在节点d3.js之间创建链接,当前返回Uncaught TypeError:无法读取属性'weight'
- Uncaught TypeError:使用变量创建对象时,undefined不是函数
- 为什么我会得到错误Uncaught TypeError:无法设置属性'显示'在Javascript中未定
- React Uncaught TypeError:无法读取属性'替换'的未定义
- KendoUI TreeView试图将脏属性添加到Poco并获取Uncaught TypeError:e.slice不是
- Bourbon Refills Navigation JavaScript错误:Uncaught TypeError:u