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 causes the mis-run?
I am creating a website where you can upload a fact to the Parse backend. So I wrote the code but it does not seem to be working. What is the problem?
<html>
<body>
<script type="text/javascript">
Parse.initialize("uZXJE7ChTK3XMvs3Nsf8hE5ivHWiGLpEimGAnUp1", "zJ9PQfiin6ZY9FXSqxFvYmuA9uOhsRz64jTWoExL");
var SomeFacts = Parse.Object.extends("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>
4 Answers
Seth Kroger
56,416 PointsIn order to use a JavaScript library, like Jquery or Parse.com's, you need to load it first before your own script. Otherwise your script won't have the necessary code loaded and objects like Parse will be undefined.
Check the docs and/or sample code from Parse.com. It should give the necessary <script> tags to include before your code.
Seth Kroger
56,416 Points<script src="//www.parsecdn.com/js/parse-1.6.7.min.js"></script> should be <script src="http://www.parsecdn.com/js/parse-1.6.7.min.js"></script>, particularly if you are previewing the page as a local file, not through a web server. Leaving off the protocol means the browser will use the same protocol to fetch the link as was used to fetch the page, which is file: not http: when previewing locally.
Also, two other things to note:
- you have an extra brace at the end of your script. That will cause a syntax error when you reach it.
- that
<center><b><i><u><h1><font color="green">...</h1></u></i></b></center></font>
a. shouldn't be wrapped around the head it should be in the body if at all, b. isn't closed in the correct order (</font> is in the wrong place), c. is better off replaced by CSS styling on an h1.
Farouk Charkas
1,957 PointsOkay. But we have updated the code to the http: link and yet it is not working
Farouk Charkas
1,957 PointsAnd now apparently it has the error as: Uncaught TypeError: Parse.Object.extends is not a function
Thank you for your patience sir
Seth Kroger
56,416 PointsCheck the Parse docs and see if extends() is really the name of the function you're looking for.
Farouk Charkas
1,957 PointsOkay, thanks.
Farouk Charkas
1,957 PointsThank you so much!
Farouk Charkas
1,957 PointsFarouk Charkas
1,957 PointsWell. I am in a team right now. So I have this script to the front-end and he initialized the actual Parse. But even for him it is not working.
Farouk Charkas
1,957 PointsFarouk Charkas
1,957 PointsFull code
[Mod - edited for formatting]
Farouk Charkas
1,957 PointsFarouk Charkas
1,957 PointsI get this for an error: Failed to load resource: net::ERR_FILE_NOT_FOUND
Farouk Charkas
1,957 PointsFarouk Charkas
1,957 PointsThis is the suspected file: //www.parsecdn.com/js/parse-1.6.7.min.js