解析连接无法正常工作

时间:2015-05-12 03:27:04

标签: javascript html parse-platform

我正在尝试将我的Web应用程序与解析数据库连接,但它无法正常工作。我用HTML和JS实现我的代码,但我不知道它是什么错,因为它没有在数据库和main.js中保存表单。我想我必须把东西放在那里,但我不知道是什么。

这是我的最终项目。

这是我的代码

<!DOCUTYPE html>

<html>
 <HTML>
    <head>
    <title>ERP WEBAPP</title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.2.15.min.js"></script>
    <script type="text/javascript">
    Parse.initialise("svw5oNs8f0aRVHQyP5RzS70yCdmpSTSHn3dbKOdo", "jX8gHEYaF2Umq2geSGeiND7ILYwFndCwA5UeZwNW");

var ParseObj = Parse.Object.extend('RegisterTable'); //create local parse object from your Parse class

//$('#submit').bind("click",function(e)){
$('#register').submit(function(e){
//on form submit
    e.preventDefault();

    //get data from form
    var data = {
        email: $('#email').val();
        username: $('#username').val();
        password: $('#password').val();
        select = $('#select :selected').text();

    }



    //create new Parse object
    parseObj = new ParseObj();

    //match the key values from the form, to your parse class, then save it
    parseObj.save({
        parseObj.set("Email", data.email);
        parseObj.set("UserName", data.username);
        parseObj.set("Password", data.password);
        parseObj.set("UserType", data.select);
    }, {
        //if successful
        success: function(parseObj){
        alert(parseObj.get('fname') + " " + parseObj.get('lname') + " " + parseObj.get('email') + " saved to Parse."
        },
        error: function(parseObj, error) {
            console.log(parseObj);
            console.log(error);
        }
    })
});
//});
    </script>
</head>
  <body>
    <div align = "center">
    <h1>Register</h1>
    <br>
      <form id="register" method="post" onsubmit="formSubmit()">
        Email: <input id="email" name="email" type="email" ><br>
        Username: <input id="username" type="text" name="username"><br>
        Password: <input id="password" type="password" name="password"><br>
          <select id="select" name="select" >
            <option value="alex">alex</option>
            <option value="maiquel">maiquel</option>
          </select>
        <input type="submit" id="submit" value="Register"style="width=100px ;height = 30px">
      </form>
    </div>
  </body>
</html>

0 个答案:

没有答案