gpt4 book ai didi

php - Pjax 无法与 PHP 一起使用

转载 作者:行者123 更新时间:2023-11-28 20:21:39 25 4
gpt4 key购买 nike

我尝试将 Pjax 添加到 PHP 站点,因为我想使用 ajax 和 PushState 动态加载内容,而 Pjax 似乎是最佳选择。

在我的site.js我有的文件:

$(document).pjax('nav li a', '.wrap');

我检查了其他答案,似乎 JS 没有错误,我想知道这是不是因为我使用的是 PHP?

更新

尽管我收到此错误,但我已从 GitHub 页面获取了 jquery.pjax.js:

Uncaught TypeError: Object [object Object] has no method 'live' 

<head>我有:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="/js/jquery.cookie.js"></script>
<script src="/js/jquery.pjax.js"></script>
<script>
$(function(){
// pjax
$('ul a').pjax('#main')
})
</script>

最佳答案

jQuery.live() 在 1.7 中已弃用,并在 1.9 中被删除。

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

http://api.jquery.com/live/

使用较旧的 jQuery 版本或更改代码或库代码以使用 .on()

看起来最新版本的 pjax 也解决了这个问题。请参阅https://github.com/defunkt/jquery-pjax#legacy-api

关于php - Pjax 无法与 PHP 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18187878/

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