Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting Parse.com object to string

What I have is when a user enters a name into a textbox and clicks a button, the value in the textbox is saved to the Parse database.

What iI'm trying to do is get the name that was added and add it to a div.

On this Live Example, it's basically what I want, except it alerts [object Object] and not thomas in this case.

like image 509
Thomas Mannion Avatar asked Mar 01 '26 00:03

Thomas Mannion


1 Answers

You need to use the specific part of the result you need. In your case, replace

query.first({
  success: function (results) {
    alert("Successfully retrieved " + results + " ");
    divTag.innerHTML = results.toString();
  },
  error: function (error) {
    alert("Error: " + error.code + " " + error.message);
  }
});

with

query.first({
  success: function (results) {
    alert("Successfully retrieved " +  results.attributes.FirstName + " ");
    divTag.innerHTML = results.attributes.FirstName.toString();
  },
  error: function (error) {
    alert("Error: " + error.code + " " + error.message);
  }
});
like image 62
Nick Andriopoulos Avatar answered Mar 03 '26 13:03

Nick Andriopoulos