本文转自:http://stackoverflow.com/questions/15840611/jquery-mobile-get-data-passed-to-page-via-changepage

Solution

Send them like this:

$.mobile.changePage('page2.html',{ dataUrl :"page2.html?parameter=123", data :{'paremeter':'123'}, reloadPage :true, changeHash :true});

And read them like this:

$("#index").live('pagebeforeshow',function(event, data){var parameters = $(this).data("url").split("?")[1];;
parameter = parameters.replace("parameter=","");
alert(parameter);});

More examples can be found here: jQuery Mobile: document ready vs page events, just look for chapter: Data/Parameters manipulation between page transitions.

Example:

index.html

<!DOCTYPE html>
<html>
<head>
<metacharset="utf-8"/>
<metaname="viewport"content="widdiv=device-widdiv, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<metaname="apple-mobile-web-app-capable"content="yes"/>
<metaname="apple-mobile-web-app-status-bar-style"content="black"/>
<title></title>
<link rel="stylesheet"href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css"/>
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script><script>
$(document).on('pagebeforeshow',"#index",function(){
$(document).on('click',"#changePage",function(){
$.mobile.changePage('second.html',{ dataUrl :"second.html?paremeter=123", data :{'paremeter':'123'}, reloadPage :false, changeHash :true});});}); $(document).on('pagebeforeshow',"#second",function(){var parameters = $(this).data("url").split("?")[1];;
parameter = parameters.replace("parameter=","");
alert(parameter);});</script></head><body><!-- Home --><divdata-role="page"id="index"><divdata-role="header"><h3>
First Page
</h3></div><divdata-role="content"><adata-role="button"id="changePage">Test</a></div><!--content--></div><!--page--></body></html>

second.html

<!DOCTYPE html><html><head><meta charset="utf-8"/>
<meta name="viewport"content="widdiv=device-widdiv, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable"content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style"content="black"/><title></title>
<link rel="stylesheet"href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css"/>
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script></head>
<body><!-- Home --><div data-role="page"id="second"><div data-role="header"><h3>
Second Page
</h3></div><divdata-role="content"></div><!--content--></div><!--page--></body></html>

More info

If you want to learn more about this topic take a look at this article. You will find several solutions with examples.

[转]jQuery Mobile: Get data passed to page via changePage mobile.changePage的更多相关文章

  1. jQuery数据缓存$.data 的使用以及源码解析

    一.实现原理: 对于DOM元素,通过分配一个唯一的关联id把DOM元素和该DOM元素的数据缓存对象关联起来,关联id被附加到以jQuery.expando的值命名的属性上,数据存储在全局缓存对象jQu ...

  2. jQuery中使用data()方法读取HTML5自定义属性data-*实例

    如果你使用jQuery类库,那么你可以非常愉悦的使用jquery的data()方法存取data-* 自定义属性,方法允许我们在DOM元素上绑定任意类型的数据,避免了循环引用的内存泄漏风险 主要的方法如 ...

  3. jQuery Ajax Post Data Example

    http://www.formget.com/jquery-post-data/ jQuery Ajax Post Data Example Fugo Of FormGet jQuery $.post ...

  4. 深入jQuery中的data()

    引入 data函数在jQuery中看起来很不起眼, 就像沙滩上一颗平凡的沙子, 但仔细一瞅, 却惊讶的发现data是jQuery中无比重要的一环, 甚至jQuery中各种事件都基于此. data有什么 ...

  5. JQuery.Ajax()的data参数类型

    假如现在有这样一个表单,是添加元素用的. <form id='addForm' action='UserAdd.action' type='post'> <label for='un ...

  6. jQuery源代码学习之六——jQuery数据缓存Data

    一.jQuery数据缓存基本原理 jQuery数据缓存就两个全局Data对象,data_user以及data_priv; 这两个对象分别用于缓存用户自定义数据和内部数据: 以data_user为例,所 ...

  7. The requested page cannot be accessed because the related configuration data for the page is invalid

    当在VS2013下开发web site时,调试时都是在IIS Express中进行的,没有问题.当部署到IIS中,出现:The requested page cannot be accessed be ...

  8. [Project] Simulate HTTP Post Request to obtain data from Web Page by using Python Scrapy Framework

    1. Background Though it's always difficult to give child a perfect name, parent never give up trying ...

  9. [asp.net core]The requested page cannot be accessed because the related configuration data for the page is invalid.

    bug HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed because the rela ...

随机推荐

  1. 《Effective Java》第3章 对于所有对象都通用的方法

    第8条:覆盖equals时请遵守通用约定 覆盖equals方法看起来似乎很简单,但是有许多覆盖方式会导致错误,并且后果非常严重.最容易避免这类问题的办法就是不覆盖equals方法,在这种情况下,类的每 ...

  2. 2016年第七届蓝桥杯省赛试题(JavaA组)

    1.结果填空 (满分3分)2.结果填空 (满分5分)3.结果填空 (满分9分)4.代码填空 (满分11分)5.代码填空 (满分13分)6.结果填空 (满分15分)7.结果填空 (满分19分)8.程序设 ...

  3. SqlBulkCopy(批量复制)使用方法 && SqlDataAdapter Update

    SqlBulkCopy提供了一种将数据复制到Sql Server数据库表中高性能的方法.SqlBulkCopy 包含一个方法 WriteToServer,它用来从数据的源复制数据到数据的目的地. Wr ...

  4. 【ionic App问题总结系列】ionic 如何更新app版本

    ionic 如何进行自动更新 ionic App更新有两种方式:第一种是普通的从远程下载apk,安装并覆盖旧版本.另外一种就是采用替换www文件夹的内容,实现应用内更新,而无需下载安装apk. 这篇文 ...

  5. js 值传递,引用传递

    参考:http://www.cnblogs.com/lcngu/p/5876273.html JS的基本类型,是按值传递的. 对象类型按共享传递的(call by sharing,也叫按对象传递.按对 ...

  6. [51nod1239] 欧拉函数之和(杜教筛)

    题面 传送门 题解 话说--就一个杜教筛--刚才那道拿过来改几行就行了-- //minamoto #include<bits/stdc++.h> #define R register #d ...

  7. P3369 【模板】普通平衡树(权值线段树)

    原来线段树还有这种操作(开成一个桶) 用区间维护在这个区间内元素的个数,离散化一下,居然能达到splay的效果 不仅码量大大减少,而且跑的飞快!!! 6种操作  200多ms 插入 xx 数 删除 x ...

  8. error : Could not load UI satellite dll 'TrackerUI.dll'. Make sure it exists in an LCID subdirectory of 'C:\Program Files (x86)\MSBuild\12.0\bin\'.

    原因  VS2013 + QT环境部署好后, 又安装了VS2015\ 解决方案:  在另一台电脑里重装VS2013, 并将  C:\Program Files (x86)\MSBuild\12.0\B ...

  9. [Shell]Shell学习笔记之for

    关于shell中的for循环用法很多,一直想总结一下,今天网上看到上一篇关于for循环用法的总结,感觉很全面,所以就转过来研究研究,嘿嘿…1. for((i=1;i<=10;i++));do e ...

  10. 利用canvas添加图片水印--直接上代码

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...