title: parse.com Reference Error: user is not defined
body: <p>I found this really cool site called <a href="http://parse.com" rel="nofollow">http://parse.com</a>. It is an online database (amongst many other things). Definitely check it out. Anyway, I believe I am one step away from figuring out how to use Parse.User, and render the objects email in an ejs template. I have it so that I can create and store users on parse.com - but I dont think that my template is recognizing the "user" variable I created. Here is my code and error:</p>
  
  <p>application.js</p>
  
  <pre><code>$(document).ready(function() {
      $("#signupform").submit(function(e) {  
          e.preventDefault();
  
          Parse.initialize("O3LAmHCCGmMWBRuPEt4cXWP5ChQMjeruyOkMN7m1", "AIyuUVnGYbyQrWaYns7TL3XpmjPb1FDeplQ76DgG");
  
          var user = new Parse.User(); 
          user.setUsername($('#username').val());
          user.setEmail($('#email').val());
          user.setPassword($('#pw').val());
  
          user.signUp();
  
          var html = new EJS({url: 'templates/usershow.ejs'}).render(user);
          var content = document.getElementById('listuser');
          content.innerHTML = content.innerHTML + html;
          $("#signupform").remove();   
      });
  });
  </code></pre>
  
  <p>templates/usershow.ejs</p>
  
  <pre><code>&lt;li&gt;&lt;%= user.getEmail() %&gt;&lt;/li&gt;
  </code></pre>
  
  <p>index.html</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;it IT&lt;/title&gt;
    &lt;link rel="stylesheet" type="text/css" href="application.css" /&gt;
    &lt;script src="jquery.js"&gt;&lt;/script&gt; 
    &lt;script src="application.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="ejs_production.js"&gt;&lt;/script&gt;
    &lt;script src="http://www.parsecdn.com/js/parse-1.2.7.min.js"&gt;&lt;/script&gt;
    &lt;!--[if lt IE 9]&gt;
    &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
    &lt;![endif]--&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;it IT&lt;/h1&gt;
      &lt;div id="signup"&gt;
          &lt;form id="signupform"&gt;
              Username: &lt;input type="text" name="username" id="username"&gt;&lt;br&gt;
              Password: &lt;input type="password" name="pw" id="pw"&gt;&lt;br&gt;
              Email: &lt;input type="text" name="email" id="email"&gt;&lt;br&gt;
              &lt;input type="submit" value="sign up"&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;div id="signin"&gt;&lt;/div&gt;
      &lt;div id="showuser"&gt;
          &lt;h2&gt;Username - Email&lt;/h2&gt;
          &lt;ul id="listuser"&gt;&lt;/ul&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The error I get in firebug(after a successful post to the parse.com database) is:</p>
  
  <p><code>ReferenceError: user is not defined</code></p>
  
  <p>The line in question seems to be the <code>var html = new EJS({url: 'templates/usershow.ejs'}).render(user);</code> line. I'm not sure if the render function can recognize a Parse.User object? Maybe a problem using ejs with Parse.User?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>In response to the comment below, I changed my code to this:</p>
  
  <pre><code>$(document).ready(function() {
      $("#signupform").submit(function(e) {  
          e.preventDefault();
  
          Parse.initialize("O3LAmHCCGmMWBRuPEt4cXWP5ChQMjeruyOkMN7m1", "AIyuUVnGYbyQrWaYns7TL3XpmjPb1FDeplQ76DgG");
  
          var user = new Parse.User(); 
          user.setUsername($('#username').val());
          user.setEmail($('#email').val());
          user.setPassword($('#pw').val());
  
          user.signUp(null, {
              success: function (user) {
                  // Hooray! Let them use the app now.
                  var html = new EJS({url: 'templates/usershow.ejs'}).render(user);
                  var content = document.getElementById('listuser');
                  content.innerHTML = content.innerHTML + html;
                  $("#signupform").remove();   
              },
              error: function (user, error) {
                  // Show the error message somewhere and let the user try again.
                  //alert("Error: " + error.code + " " + error.message);
                  console.log("Error: " + error.code + " " + error.message);                        
              }
          });
      });
  });
  </code></pre>
  
  <p>While I think this corrected a problem with my code...I am still getting the same error, stated above.</p>
  
  <p>Again, I'm coming back to this line <code>var html = new EJS({url: 'templates/usershow.ejs'}).render(user);</code> as the culprit...just because the user object is a Parse.User object and not just a regular object?</p>