javascript - Parse.com Form not sending information, submit error? -


just wondering if knows why form won't store data in parse database?

i think might submit button...

html 5 form, supposed integrate parse.com, sorry javascript isn't strongest language.

 <div class="register span5 offset3">             <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">                 <h2>create account <!--<span class="red"><strong>iapp</strong></span>--></h2>                 <input type="text" id="firstname" name="firstname" placeholder="first name">                 <input type="text" id="lastname" name="lastname" placeholder="last name">                 <input type="text" id="username" name="username" placeholder="username">                 <input type="text" id="email" name="email" placeholder="email address">                 <input type="password" id="password" name="password" placeholder="password">                 <button type="submit" onclick="signup();">sign up</button>             </form>         </div>         </div>  <script type="text/javascript">      parse.initialize("xxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");      function signup() {          var firstname = document.getelementbyid("firstname").value;         var lastname = document.getelementbyid("lastname").value;         var username = document.getelementbyid("username").value;         var password = document.getelementbyid("password").value;         var mail = document.getelementbyid("email").value;      var user = new parse.user();     user.set("firstname", firstname);     user.set("lastname", lastname);     user.set("username", username);     user.set("password", password);     user.set("email", mail);          // other fields can set parse.object     user.set("phone", "650-555-0000");      user.signup(null, {         success: function(user) {             // hooray! let them use app now.         },         error: function(user, error) {             // show error message somewhere , let user try again.             alert("error: " + error.code + " " + error.message);         }     }     }     ); </script> 

try coupling signup function submit eventhandler:

<div class="register span5 offset3">             <form id="signupform">                 <h2>create account <!--<span class="red"><strong>iapp</strong></span>--></h2>                 <input type="text" id="firstname" name="firstname" placeholder="first name">                 <input type="text" id="lastname" name="lastname" placeholder="last name">                 <input type="text" id="username" name="username" placeholder="username">                 <input type="text" id="email" name="email" placeholder="email address">                 <input type="password" id="password" name="password" placeholder="password">                 <button type="submit">sign up</button>             </form>         </div>         </div>  <script type="text/javascript">      parse.initialize("xxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxx");      function signup(e) {        //preventdefault form doesnt reload page         e.preventdefault();          var firstname = document.getelementbyid("firstname").value;         var lastname = document.getelementbyid("lastname").value;         var username = document.getelementbyid("username").value;         var password = document.getelementbyid("password").value;         var mail = document.getelementbyid("email").value;      var user = new parse.user();     user.set("firstname", firstname);     user.set("lastname", lastname);     user.set("username", username);     user.set("password", password);     user.set("email", mail);          // other fields can set parse.object     user.set("phone", "650-555-0000");      user.signup(null, {         success: function(user) {             // hooray! let them use app now.         },         error: function(user, error) {             // show error message somewhere , let user try again.             alert("error: " + error.code + " " + error.message);         }     }     }     );      document.getelementbyid('signupform').addeventlistener('submit', signup); </script> 

what have done here couple submit event of form id "signup" event "submit". when button pressed trigger event , listener gets executed.

document.getelementbyid('signupform').addeventlistener('submit', signup); 

also aware of e.preventdefault() have added @ top of function prevent pagereload (which done default on form submit)

just check out changes i've made

i hope helps


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -