2014-01-14 178 views
0

大家好我正嘗試使用parse.com和javascript爲我的網站使用表單創建登錄函數。但是,我一直在獲取Uncaught ReferenceError:當我測試它時,myfunction未定義錯誤。任何幫助將不勝感激。未捕獲ReferenceError:未定義myfunction Parse.com

感謝球員我已經添加了刪除未捕獲的ReferenceError的引號:myfunction未定義錯誤。但是我現在得到一個Uncaught ReferenceError:$沒有定義錯誤。我將如何去除這個錯誤?

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title>Sign Up</title> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, intial-scale=1.8" /> 
    <script type="text/javascript" src="//www.parsecdn.com/js/parse-1.2.16.min.js"></script> 
    <script type="text/javascript"> 
      function myfunction() { 
       var user = new Parse.User(); 
       user.set("FirstName", $(#signup-upFirstName).val()); 
       user.set("Surname", $(#signup-Surname).val()); 
       user.set("EmailAddress", $(#signup-Confirmemailaddress).val()); 
       user.set("Password", $(#signup-ConfirmPassword).val()); 

       user.signUp(null, { 
        success: function (user) { 
         // Hooray! Let them use the app now. 
        }, 
        error: function (user, error) { 
         // Show the error message somewhere and let the user try again. 
         alert("Error: " + error.code + " " + error.message); 
        } 
       }); 
      }; 

     </script> 
    <style type="text/css"> 
     .auto-style1 { 
      width: 156px; 
     } 
    </style> 
</head> 
<body> 
    <div> 

    <form> 
     First Name: <input id="signup-FirstName" type="text" placeholder="Firstname"required="" /> 
     Surname: <input id="signup-Surname" type="text" placeholder="Surname" required=""/> 
     Email Address:<input id="signup-EmailAddress" type="text" placeholder="EmailAddress" required=""/> 
     Confirm Email Address: <input id="signup-Confirmemailaddress" type="text" placeholder="confirmemailaddress" required =""/> 
     Password: <input id="signup-password" type="password" placeholder="password" required="" /> 
     Confirm Password: <input id="signup-ConfirmPassword" type="password" placeholder="confirmpassword" required="" /> 
     <input type="submit" onclick="myfunction();" value="Next" /> 
    </form> 
    </div> 



</body> 
</html> 
+0

你能設置一個http://jsfiddle.net/? – felipekm

回答

1

您的函數有幾個語法錯誤,所以解析停止,函數從未定義過。

$(#signup-upFirstName).val()); 

你錯過了周圍"#signup-upFirstName"引號和您的其它jQuery選擇。 jQuery選擇器只是普通的字符串,它們需要引號。

+0

另外他錯過了jQuery

0

您在jQuery選擇器中缺少引號。

function myfunction() { 
       var user = new Parse.User(); 
       user.set("FirstName", $('#signup-upFirstName').val()); 
       user.set("Surname", $('#signup-Surname').val()); 
       user.set("EmailAddress", $('#signup-Confirmemailaddress').val()); 
       user.set("Password", $('#signup-ConfirmPassword').val()); 

       user.signUp(null, { 
        success: function (user) { 
         // Hooray! Let them use the app now. 
        }, 
        error: function (user, error) { 
         // Show the error message somewhere and let the user try again. 
         alert("Error: " + error.code + " " + error.message); 
        } 
       }); 
      }; 
相關問題