weixin_33725722 2016-07-01 08:10 采纳率: 0%
浏览 61

使用pushState()的AJAX

I found wonderfull article, which explain how to use pushState with AJAX. https://moz.com/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate

But I can't figure out how organized "content.php" file. In comments this question is often asked, but nobody answered to this. This is quite important, because without "content.php" nothing works.

May be somebody know the example of "content.php"? I will appreciate it. Thanks

  • 写回答

2条回答 默认 最新

  • Lotus@ 2016-07-01 08:45
    关注

    The code in the link you provided is making a simple get request to a PHP file called content.php. The PHP file then returns a JSON as the response.

    What I'm about to write down next is the bare-bones example of how to set up the content.php file, it is not recommended, but for just an example, you can do this

    <? php
    
    $contentId = $_GET['contnentid'];
    doSomethingWith($contentid) 
    
    public function doSomethingWith($contentId)
    {
        //get content with id from db or somewhere
        return json_encode(['Content' => 'Some content']);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大