获取用于在页面上加载 div 的 URI?
我在通过 jQuery 的 .load() 函数加载的 PHP 生成的页面上有一个 div。该 div 包含一个已分页的长列表(第 1、2、3...25 页等的链接)。我想编写一个函数,它将保留 URI 的“搜索”部分中的变量(也就是说在 URI 的末尾:?foo=1&bar=pancakes)并粘贴在 &page= 上X在最后。然而,要做到这一点,我必须以某种方式检索从该 div 中加载该 div 的当前 URI。
window.location.search 显然只从父页面检索信息,所以这没有帮助。 .js 文件是静态加载的,因此我无法将 PHP 插入 Javascript 中间来设置变量。我什至无法将分页链接移到父页面中,因为当列表中的条目数发生变化时,我需要更新页数。我不知道如何完成这项任务。任何建议将不胜感激。
编辑:链接全部由 jQuery 处理,以使用新信息加载 div - 因此 .load()
I have a div on a PHP-generated page loaded through jQuery's .load() function. This div contains a long list which has been paginated (links for page 1, 2, 3... 25, etc.). I'd like to write a function which will preserve the variables in 'search' portion of the URI (which is to say at the end of the URI: ?foo=1&bar=pancakes) and stick on a &page=X at the end. However, to do that, I must somehow retrieve the current URI which loaded the div from within that div.
window.location.search obviously only retrieves information from the parent page, so that's no help. The .js files are loaded in statically, so I can't stick PHP into the middle of the Javascript to set variables. I can't even move the pagination links into the parent page, because I need the number of pages to update when the number of entries in the list changes. I'm at a loss as to how I might accomplish this task. Any suggestions would be greatly appreciated.
EDIT: The links are all handled by jQuery to load the div with the new information -- hence the .load()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需循环遍历
$_GET
变量即可:Simply loop through the
$_GET
variable: