Bộ nhớ cục bộ HTML5 có hoạt động trong Cordova/PhoneGap không? Tôi đang cố gắng sử dụng nó, cả cách HTML5 và cách được chỉ định trong tài liệu. Không làm việc.HTML5 localstorage trong Cordova
Cụ thể, tôi đang cố sử dụng kết quả truy vấn ajax để lưu trữ cục bộ. Tôi đã thử nghiệm truy vấn và nó hoạt động.
<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>
Bạn đã đảm bảo rằng môi trường mà bạn đang thử nghiệm trong hỗ trợ lưu trữ cục bộ HTML5? –
Tính năng này hoạt động mà không gặp bất kỳ sự cố nào trong PhoneGap. Vui lòng cho chúng tôi thấy mã của bạn để chúng tôi có thể xem có bất kỳ điều gì không đúng với mã của bạn. –
Làm cách nào để kiểm tra môi trường để được hỗ trợ lưu trữ cục bộ? – copilot0910