我正在尝试使用Parse API创建登录表单。但每当我这样做,我得到 解析错误400(错误请求){代码:201,消息:“缺少用户密码”}。我在一个简单的主机上尝试过它,但它没有同样的错误。这是我的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);
}
});
});
});
我的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>
和我的Parse DATABASE的图像
答案 0 :(得分:1)
因为jQuery不使用.value
$('#inputUsername').value, $('#inputPassword').value
应该是
$('#inputUsername').val(), $('#inputPassword').val()