HTML5 本地存储是否在 Cordova / PhoneGap 中工作?我正在尝试使用 HTML5 方式和文档中指定的方式。都不工作。
具体来说,我正在尝试使用 ajax 查询结果进行本地存储。我已经测试了查询,它可以工作。
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="format-detection" content="telephone=no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi">
<title>Hello World</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js" type="text/javascript">
</script>
<script type="text/javascript">
$(document).ready(function () {
$("form").submit(function () {
var uname = document.getElementById("username").value;
var pword = document.getElementById("password").value;
var postData = {
username: uname,
password: pword
};
$.ajax({
url: "http://www.yellowcabsavannah.com/test.php",
type: "POST",
data: postData,
async: false,
dataType: 'json',
cache: false,
success: function (data) {
localStorage.uname = data.username;
localStorage.pword = data.password;
alert(localStorage.uname);
}
}
});
return false;
});
});
</script>
</head>
<body>
<form action="">
<input type='text' id="username" name="username" placeholder="Username">
<br>
<input type='password' id="password" name="password" placeholder="password">
<br>
<input type="submit" id="submit" value="Login">
</form>
</body>