如何使用jquery“加载”?传递变量时加载页面片段的方法?
不确定是否有人问过这个问题,但给出以下代码,就这样了...
$('#infoPane').load('showInfo.php #info');
如何将变量传递到页面但仅加载页面片段?
$('#imgPane').load('showInfo.php?q='+$q+ '#picture');
上面的代码不起作用,所以任何帮助将不胜感激
Not sure if this has been asked, but here it goes, given the following code...
$('#infoPane').load('showInfo.php #info');
How do a pass variable to the page yet only just load the page fragment?
$('#imgPane').load('showInfo.php?q='+$q+ '#picture');
The above code does not work so any help would be appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它可能不起作用,因为间距不正确:
在您的示例中,您尝试加载:
showInfo.php?q=whatever#picture
而不是showInfo.php?q=不管 #picture
但是,您应该能够将数据发布到您的脚本,类似于以下内容:
传递数据是 jQuery .load() 参数。
It probably doesn't work because the spacing is incorrect:
In your example, you're trying to load:
showInfo.php?q=whatever#picture
rather thanshowInfo.php?q=whatever #picture
However, you should be able to post data to your script similar to the following:
Passing data is one of the jQuery .load() parameters.
我不知道 jQuery 在这里是如何工作的,确切地说,但是使用 URL 哈希作为 ID 似乎很奇怪。它大概应该是这样的:
I do not know how jQuery works here, exactly, but using the URL hash as ID seems odd. It should probably look like this:
生成的 URL 不遵循“神奇”语法:
#
,但显示为showInfo.php?q=#picture
(无空格) 。尝试:或者,您是否尝试通过第二个参数(
data
)传递值?The resulting URL does not follow the "magic" syntax:
<url> #<id-of-fragment-to-load>
, but comes out asshowInfo.php?q=<value-of-$q>#picture
(no space). Try:Alternatively, did you try passing the value via the second argument (
data
)?