简体   繁体   English

解析错误400(错误请求){code:201,消息:“缺少用户密码”}}

[英]Parse error 400 (Bad request) {code: 201, message: “missing user password”}

Im trying to make a login form using the Parse API. 我正在尝试使用Parse API制作登录表单。 But whenever i do that I get Parse error 400 (Bad request) {code: 201, message: "missing user password"}. 但是每当我这样做时,我都会收到解析错误400(错误请求){code:201,消息:“缺少用户密码”}}。 I tried it on the a simple host but it doesn't work same error. 我在一个简单的主机上尝试过,但无法正常工作。 Here is my javascript code: 这是我的JavaScript代码:

 $(function() {

Parse.$ = jQuery;


// Replace this line with the one on your Quickstart Guide Page
 Parse.initialize("IywTDZXLZitjIx4DkeWGusACi5o2RuMurKTMjhuY", "hjx2SUDbMaIfABOtvUiAAy4VaDAEcZM6boy0aQnN");

$('.form-signin').on('submit', function(e) {

// Prevent Default Submit Event
e.preventDefault();

// Call Parse Login function with those variables
Parse.User.logIn($('#inputUsername').value, $('#inputPassword').value, {
    // If the username and password matches
    success: function(user) {
        alert('Welcome!');
    },
    // If there is an error
    error: function(user, error) {
        console.log(error);
    }
});

});


});

And my HTML code 还有我的HTML代码

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">     </script>
    <!-- Parse.js -->
    <script src="http://www.parsecdn.com/js/parse-1.6.12.min.js"></script>

  </head>
  <body>
   <div class="container">

       <form class="form-signin">
        <h2 class="form-signin-heading">Please sign in</h2>
        <label for="inputUsername" class="sr-only">Username</label>
        <input type="text" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
        <div class="checkbox">
        </div>
        <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
      </form>

    </div> <!-- /container -->


    </div><!-- /.container -->




    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
    <script src="js/admin.js"></script>

    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/admin.css" rel="stylesheet">
  </body>
   </html>

and an image of my Parse DATABASE 和我的解析数据库的图像

Parse Database 解析数据库

Beacause jQuery does not use .value 因为jQuery不使用.value

$('#inputUsername').value, $('#inputPassword').value

should be 应该

$('#inputUsername').val(), $('#inputPassword').val()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM