Building on the accepted answer above. Here is an example to pull multiple images back onto the page.
var GlobalBadges = Parse.Object.extend("GBadges");
var query = new Parse.Query(GlobalBadges);
query.exists("Global_Badge_Name");
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('Global_Badge_Name'));
}
// 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] + "'/>");
}
},
error: function(error) {
// If the query is unsuccessful, report any errors
alert("Error: " + error.code + " " + error.message);
}
});
</script>
<div id="imgs"> </div>
</body>
</html>
And this example shows you have to pull multiple images and define them in a div.
var GlobalBadges = Parse.Object.extend("GBadges");
var query = new Parse.Query(GlobalBadges);
query.exists("Global_Badge_Name");
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('Global_Badge_Name'));
}
$('#Image01').attr('src',imageURLs[0]); //first image
$('#Image02').attr('src',imageURLs[1]); //second image
$('#Image03').attr('src',imageURLs[2]); //third image
},
error: function(error) {
// If the query is unsuccessful, report any errors
alert("Error: " + error.code + " " + error.message);
}
});