HTML5本地存储在科尔多瓦

前端之家收集整理的这篇文章主要介绍了HTML5本地存储在科尔多瓦前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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>

解决方法

我已经使用了这样的本地存储:
// To store a value
window.localStorage.setItem('key',value);

// To retrieve a value
value = window.localStorage.getItem('key');

// To delete a storage
window.localStorage.removeItem('key');

希望有帮助.

原文链接:https://www.f2er.com/html5/168691.html

猜你在找的HTML5相关文章