大家好我正在尝试使用parse.com和javascript为我的网站创建一个使用表单的登录功能。但是我继续获取Uncaught ReferenceError:myfunction在我测试时没有定义错误。任何帮助将不胜感激。
谢谢大家,我添加了删除了未捕获的ReferenceError的引号:myfunction未定义错误。但我现在得到一个未捕获的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 :(得分:1)
您的函数有几个语法错误,因此解析停止并且函数永远不会被定义。
$(#signup-upFirstName).val());
你在"#signup-upFirstName"
和你的其他jQuery选择器周围缺少引号。 jQuery选择器只是常规字符串,它们需要引号。
答案 1 :(得分: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);
}
});
};