Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phonegap ajax和php_Php_Jquery_Ajax_Cordova - Fatal编程技术网

Phonegap ajax和php

Phonegap ajax和php,php,jquery,ajax,cordova,Php,Jquery,Ajax,Cordova,我不熟悉jquery和phonegap,我在任何地方都找不到问题的答案 这是我的index.html <!DOCTYPE HTML> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-type" content="text/html; chars

我不熟悉jquery和phonegap,我在任何地方都找不到问题的答案

这是我的index.html

    <!DOCTYPE HTML>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">    
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Auth Demo 2</title>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css" />
    <script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
    <script src="jquery.mobile/jquery-1.7.2.min.js"></script>
    <script src="jquery.mobile/jquery.mobile-1.1.0.min.js"></script>
    <script src="main.js"></script>
</head>

<body onload="init()">

<div id="launcherPage" data-role="page">
    <!-- I'm just here waiting for deviceReady -->
</div>

<div id="loginPage" data-role="page">

    <div data-role="header">
        <h1>Auth Demo</h1>
    </div>

    <div data-role="content">    

        <form id="loginForm">
        <div data-role="fieldcontain" class="ui-hide-label">
            <label for="username">Username:</label>
            <input type="text" name="username" id="username" value="" placeholder="Username" />
        </div>

        <div data-role="fieldcontain" class="ui-hide-label">
            <label for="password">Password:</label>
            <input type="password" name="password" id="password" value="" placeholder="Password" />
        </div>

        <input type="submit" value="Login" id="submitButton">
        </form>

    </div>

    <div data-role="footer">
        <h4>&copy; Camden Enterprises</h4>
    </div>

</div>

</body>
</html>
这不是我自己的作品,但从这里开始

我将示例中的代码更改为使用php。这非常简单,仅用于测试目的

php在这里

<?//get the posted values

    require_once("backend/functions.php");
    dbconn(true);

    $username = $_POST['user_name'];

    if ($username=='Steven'){
                    echo "yes";
    }else{

        echo "no";
    }



    ?>

现在所有这些都可以工作了,当条件满足时,页面some.html就会打开

现在我的问题是。 如何将登录用户的用户名发送到some.html页面?
从php文件确认后。

您应该能够访问

window.localStorage["username"]

在你的some.html页面上,在some.html$(document).ready(function(){var login=window.localStorage.getItem(“username”);$(“p”).append($login);})的头部有这样的内容;是的,localStorage非常适合存储需要保留的信息,以便在phonegap应用程序的各个部分进行显示或操作。
window.localStorage["username"]