Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Farouk Charkas
1,957 PointsWhat is causing this mis-run?
I have cleared my code of all errors. But one, this one is asking for the following:
Uncaught TypeError: A ParseQuery must be constructed with a ParseObject or class
This has been 'bugging' me for the past hour. Get it? Below is the code I have written so far:
<html>
<center><b><i><u><h1><font color="green">
<head> Welcome to Evergreen!
<title> Evergreen
</title>
<script src="http://www.parsecdn.com/js/parse-1.6.7.min.js"></script>
</head></font></h1></u></i></b></center>
<body bgcolor="white">
<div id="main">
<div style="display:none" class="error">
Looks like there was a problem saving the test object. Make sure you've set your application ID and javascript key correctly in the call to <code>
Parse.initialize</code> in this file.
</div>
<ul id = "list-all-the-facts-given">
</ul>
</div>
<script type="text/javascript">
Parse.initialize("uZXJE7ChTK3XMvs3Nsf8hE5ivHWiGLpEimGAnUp1", "zJ9PQfiin6ZY9FXSqxFvYmuA9uOhsRz64jTWoExL");
var query = new Parse.Query( SomeFacts );
function getInformation() {
console.log("Hi");
var query = new Parse.Query( SomeFacts );
query.find({ success: function( results ) {
var output = "";
for (var i in results) {
var theInformation = results[i].get("actualInformation");
output += "<li>";
output += "<p>" + theInformation + "</p>";
output += "</li>";
}
console.log("I got to line 35, finished function getInformation() declaration.");
$("#list-all-the-facts-given").html(output);
}, error: function( error ) {
alert("There was an error, this error is " + error.message );
}
})
}
getInformation();
var SomeFacts = Parse.Object.extend("SomeFacts");
getInformation();
var theFacts = new SomeFacts();
var supplyInfo = prompt("Enter information: ");
theFacts.set( "actualInformation" , supplyInfo );
theFacts.save(null, {
success: function(theFacts) {
alert('New object created with objectId=: ' + theFacts.id);
},
error: function(theFacts, error) {
alert('Failed to create new object, with error code: ' + error.message);
}
})
</script>
</body>
</html>
1 Answer
jason phillips
18,131 PointsCouple of things to get you going:
var query = new Parse.Query( SomeFacts );
should be
var query = new Parse.Query("SomeFacts");
you aslo need to add the script for jquery like you have for parse.
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>