2016-01-05 65 views
0

我試圖使用Parse API製作登錄表單。但每當我這樣做,我得到 解析錯誤400(錯誤的請求){代碼:201,消息:「缺少用戶密碼」}。我在一個簡單的主機上嘗試過它,但它不起作用相同的錯誤。這裏是我的javascript代碼:解析錯誤400(錯誤的請求){code:201,message:「missing user password」}

$(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

回答

1

東陽jQuery的不使用.value的

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

應該是

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

它工程的傢伙。非常感謝你的答案 – MatejMecka