对不起,如果我重复已经解决的问题。我有基于 phonegap 的身份验证过程:
AVD:安卓 4.2.2
<head>
<script type="text/javascript" charset="utf-8" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.mobile-1.2.0.min.js"></script>
<script type="text/javascript" charset="utf-8" src="cordova-2.4.0.js"></script>
<script type="text/javascript" charset="utf-8" src="main.js"></script>
</head>
<body>
<form id="loginForm">
<div data-role="fieldcontain" class="ui-hide-label">
<input type="text" name="username" id="username" value="" /></div>
<div data-role="fieldcontain" class="ui-hide-label">
<input type="password" name="password" id="password" value="" /></div>
<div data-role="fieldcontain" class="ui-hide-label">
<select name="coursetype" id="coursetype">
<option value="1">Type 1</option>
<option value="2">Type 2</option>
</select></div>
<!-- Below is 43th line -->
<input type="submit" value="Login" id="submitButton" onclick="handleLogin();" />
</form>
</body>
在main.js中使用适当的代码过程:
function handleLogin() {
var form = $("#loginForm");
var u = $("#username", form).val();
var p = $("#password", form).val();
var t = $("#coursetype", form).val();
if(u!= '' && p!= '' && t!= '') {
alert('Values are: ' +u+ ' & ' +p+ ' & ' +t);
} else {
alert('Field(s) were empty');
}
}
通过单击登录按钮,它会显示以下内容:
Uncaught ReferenceError: handleLogin is not defined at file:///android_asset/www/index.html:43
任何帮助,将不胜感激。