Jquery mobile-如何在two.html中检索从one.html传递的数据

Jquery mobile - how to retrieve the data passed from one.html in two.html?

本文关键字:html one 数据 检索 mobile- two Jquery      更新时间:2023-09-26

我关注了这个链接:

使用jquery移动在页面之间传递参数

但它所做的只是

 1) pass a parameter to a new HTML page(one.html->two.html)
 2) Read what's been passed from one.html in one.html before page disappears.
 - but i want to read the data in two.html, not in one.html

不是吗?我可能错了。但代码似乎就是这么做的。

在one.html中,我将数据传递给two.html,如下所示:

$( document ).delegate("#page1", "pageinit", function() {
    $.mobile.changePage('two.html', { 
        dataUrl : "two.html?paremeter=123", 
        data : { 'paremeter' : '123' }, 
        reloadPage : true, changeHash : true
    });
});

如何从two.html检索这些数据?

在two.html 中

$(document).on('pageshow', "#twoIndex", function (event, data) {
    var parameters = $(this).data("url").split("?")[1];;
    parameter = parameters.replace("parameter=","");  
    alert(parameter);
});

考虑使用localStorage和sessionStorage。欲了解更多信息,请查看gajotres的博客文章。