gpt4 book ai didi

javascript - 拦截 jQuery 移动页面流,在页面更改之前解析 JSON

转载 作者:行者123 更新时间:2023-11-30 13:14:09 25 4
gpt4 key购买 nike

使用 jQuery Mobile 的正常页面流看起来有点像这样:

  1. Starts on static page (foo.html)
  2. Clicks link
  3. End up on another static page (bar.html)

我需要改变这种行为。我正在寻找这样的东西:

  1. Starts on static page (foo.html)
  2. Clicks link
  3. Gathers json from server (based on i.e a how a form looks)
  4. Renders the other page (bar.html) based on the data gathered from the previous step

通常,我只是通过带有 POST/GET 的 PHP 脚本来完成此操作。但是,该项目是一个 PhoneGap 项目,因此这不是替代方案。

一个可能的解决方案是,如果我能以某种方式将第一页的表单指向第二页,那么第二页就能够获取第一页的后置参数。不过,这感觉很老套。我还更喜欢在显示第二页之前对其进行解析,这会变得更加复杂。

我怎样才能实现这种行为?更确切地说;如何在页面之间传递数据?

最佳答案

$.mobile.changePage("newPage.html", {data:{param1:'value1'}});

然后在 newPage.html 上

var url = $.url(document.location);
var param1 = url.param("param1");

这对你有帮助吗?

关于javascript - 拦截 jQuery 移动页面流,在页面更改之前解析 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12748576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com