本文转自: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. Android二维码扫描功能的集成开发

    二维码开发主要依赖ZXing开源项目 项目地址:https://github.com/zxing/zxing 这个开源项目可以扫描一维,和二维码, 一维码指的是书后面的条形码 首先配置ZXing库和A ...

  2. const 在C++中的区别

    一.Const作用    如下表所示: No. 作用 说明 参考代码 1 可以定义const常量 const int Max = 100; 2 便于进行类型检查 const常量有数据类型,而宏常量没有 ...

  3. MacBook Pro (13 英寸, 2017 年)安装win10系统

    准备: windows10系统镜像 16G或更大容量U盘(存放驱动,必须格式化为FAT) 官方提供的驱动软件 详细步骤: 1.打开Bootcamp,选择镜像文件 2.点击下一步,选择Bootcamp分 ...

  4. Category 分类

    1.Category 1)分类/类别(category): 允许以模块的方式向现有类定义添加新的方法(默认不能添加实例变量).用以扩展自己或他人以前实现的类,使它适合自己的需要. 分类的名称括在类名之 ...

  5. 洛谷P4360 [CEOI2004]锯木厂选址(斜率优化)

    传送门 我可能根本就没有学过斜率优化…… 我们设$dis[i]$表示第$i$棵树到山脚的距离,$sum[i]$表示$w$的前缀和,$tot$表示所有树运到山脚所需要的花费,$dp[i]$表示将第二个锯 ...

  6. Python之运算符以及基本数据类型的object

    一.运算符 1.算术运算符 % 求余运算 **   幂-返回x的y次幂 //   取整数-返回商的整数部分,例:9//2输出结果是4 2.比较运算符 == 等于 != 不等于 <> 不等于 ...

  7. js初识

    01-Javascript简介   Web前端有三层: HTML:从语义的角度,描述页面结构 CSS:从审美的角度,描述样式(美化页面) JavaScript:从交互的角度,描述行为(提升用户体验) ...

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

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

  9. Drop user 报ORA-00600 [KTSSDRP1]

    一客户删除一个数据库用户THH时报错: 说明在获取seg$时没有找到相应的条目,先来解释下这个600错误的参数含义: Arg [a] Tablespace number Arg [b] File nu ...

  10. 用C#写一个函数,在一个数组中找出随意几个值相加等于一个值 与迭代器对比

    算法!用C#写一个函数,在一个数组中找出随意几个值相加等于一个值比如,数组{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}  要找出那些数相加等 ...