weixin_33724059 2014-11-01 18:11 采纳率: 0%
浏览 40

页面使用Ajax重新加载为空

I created an application in static HTML, and now I had an idea:

Use a wordpress plugin that transform wordpress pages into JSON objects (titles, subtitles, content, dates, etc), then i could pull the content in my static html application using ajax = the WP becomes my CMS.

Ok, it's working, is showing the information, but now comes the real problem:

The ajax is trigger every time the user clicks on the landing page in the menu, for example:

1 - The user clicks on "About Us" in the menu. 2 - Ajax is trigger and pulls the information from the page "About Us" in Wordpress 3 - The content is displayed in html.

PROBLEM: If the user reload the pages, the content will not show anymore.

How can i fix that?

  • 写回答

1条回答 默认 最新

  • weixin_33671935 2014-11-01 18:15
    关注

    If you want a page reload to bring back the exact same dynamically constructed content you had, then you have to do two things:

    1. Whenever you dynamically modify the page, you have to update the URL (in a way that doesn't reload the page) so that the URL contains enough information to convey to your code what the state of the page is.

    2. When your page loads, you must look at the parameters in the URL and rebuild the desired page as part of the page initialization.

    One common way to do this is to use a hash tag in the URL (e.g. information after the #) to convey the state of the page. Then, after a reload, your page initialization code will look at the hash tag in the URL to figure out what dynamic content it should add to the page to reconstruct the page as it was.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!