Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Farouk Charkas
Farouk Charkas
1,957 Points

What causes this mis-run? (Part 2)

Thanks to Seth Kroger , I was able to finish Step 1 of my project but when I added Step 2, my code started acting up again. This is my code:

<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");

 function getInformation() {
  var output = "";
  var query = new Parse.Query( SomeFacts );
  query.find({ success: function( results ) {
   for (var i in results) {
    var theInformation = results[i].get("actualInformation");
    output += "<li>";
    output += "<p>" + theInformation +  "</p>";
    output += "</li>";
   }

  $("#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");
 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

Couple 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>