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']);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 高价求抖音抓包技术,抖音抓包无网络问题
  • ¥15 【matlab】已知功率谱密度反求时域信号
  • ¥15 mindspore项目_模型适配
  • ¥15 openstack使用cinder后,实例运行时分配的总空间不能大于ceph的总空间
  • ¥15 [pcl::PLYWriter::writeASCII] Error during opening (?鶂?)!
  • ¥15 得到XY两轴的数据如何绘制成圆,输入整形器
  • ¥29 PHP读取PDF文件添加多个数字签名
  • ¥25 联邦学习vgg修改最后一个全连接层报错(默认是1000个输出,我的改为11就报错,改为200就没问题)
  • ¥15 maple画图问题,为什么会是这样
  • ¥15 RC522开发arduino作品刷卡失效