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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵