Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/450.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
Javascript jQuery移动设备在页面之间检索数据_Javascript_Jquery_Jquery Mobile - Fatal编程技术网

Javascript jQuery移动设备在页面之间检索数据

Javascript jQuery移动设备在页面之间检索数据,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,我在phonegap应用程序中使用jquery mobile,并尝试将一个变量从文本框传递到下一页,以使用该变量执行xml遍历 我的页面使用javascript发送变量,但我不知道如何在下一页检索它 <script type="text/javascript"> $("#s-sur").live('pageinit', function() { $("#search").click(function() { $.m

我在phonegap应用程序中使用jquery mobile,并尝试将一个变量从文本框传递到下一页,以使用该变量执行xml遍历

我的页面使用javascript发送变量,但我不知道如何在下一页检索它

<script type="text/javascript">
    $("#s-sur").live('pageinit', function() {

            $("#search").click(function() { 
                 $.mobile.changePage( "ssname.html", {
                type: "post",
                data: $("#search").serialize()
                                                        });
            });

    });
</script>

$(“#s-sur”).live('pageinit',function(){
$(“#搜索”)。单击(函数(){
$.mobile.changePage(“ssname.html”{
类型:“post”,
数据:$(“#搜索”).serialize()
});
});
});

服务器端语言必须解析
ssname.html
文件才能获取POST变量。但是,您可以从JavaScript访问和获取变量:

$("#s-sur").live('pageinit', function() {
    $("#search").click(function() { 
        $.mobile.changePage( "ssname.html", {
            type : "get",
            data : $("#search").serialize()
        });
    });
});
然后对于
ssname.html
页面:

$("#ssname").live('pageinit', function() {
    //now you can get your variables from the URL: location.search
});
也可以使用全局变量在页面之间保存信息:

$("#s-sur").live('pageinit', function() {
    $("#search").click(function() {
        window.myCustomVariable = $("#search").serialize();
        $.mobile.changePage("ssname.html");
    });
});

然后在
ssname.html
页面上,您只需阅读
窗口.myCustomVariable
变量即可完成工作。这是因为页面将出现在同一个DOM中,因此这两个页面都将存在
窗口.myCustomVariable
变量。

非常感谢。真的很有帮助。