Sorry for the long post, but I'm not sure if the problem occurs without all the code.
I use parse.com and the JavaScript SDK.
The code below is part of my user profile page, it displays their profile picture on the screen and allows them to change it.
Changing the profile image works fine and loads as expected. The problem is that on the profile page, the profile displays the first image of the user and displays it on the page for any user. Basically, he does not look at the current user.
I think I need to update the query to include something like var currentUser = Parse.User.current(); and enter it into your code. Be that as it may, I try to do it, I hit a brick wall. Any help would be great
I am afraid, if so, to understand how to change the code to avoid this?
/////////////////////////Queries the users profile picture and shows on page//////////////////////// var UserProfilePic = Parse.Object.extend("_User"); var query = new Parse.Query(UserProfilePic); query.exists("ProfilePic"); 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('ProfilePic').url()); } // If the imageURLs array has items in it, set the src of an IMG element to the first URL in the array if (imageURLs.length > 0) { $('#profile_pic').attr('src', imageURLs[0]); } $('#Image01').attr('src', imageURLs[0]); //first image }, error: function(error) { // If the query is unsuccessful, report any errors alert("Error: " + error.code + " " + error.message); } }); ///////// Saves the users profile image and fields after the
source share