从外部网页内容加载到使用Ajax / jQuery的另一页 [英] Load content from external page into another page using Ajax/jQuery
问题描述
有没有办法做到这一点?
page1.php中 --has
< DIV ID =主>
< DIV ID =内容>你好< / DIV>
< / DIV>
的index.php --has
< DIV ID =主>
< / DIV>
我可以以某种方式抓住从page1.php中的数据内容
div中,并加载到主
格在我的index.php?
我跟在CSS-招数URL提供的code做到了这一点:的http:// css-tricks.com/examples/DynamicPage/
但这种使用哈希改变事件。我不希望使用散列功能,只需加载内容的功能,但我似乎无法隔离$ C $下,因为我认为这是内置在烧烤hashchange插件。
有没有做这件事的一个Ajax方式?
类似于
$(选择).find('#主)的负载('#内容)。
只要把过滤选择在 .load
的第一个参数:
$(文件)。就绪(函数(){
$(#主)的负载('#内容page1.php中)。
});
这会在当前页面#内容从page1.php中的内容注入#main DIV。
Is there a way to do this?
page1.php --has
<div id="main">
<div id="content">hello</div>
</div>
index.php --has
<div id="main">
</div>
Can I somehow grab the data from page1.php inside of the content
div and load it into the main
div in my index.php?
I have done this with the code provided at css-tricks url: http://css-tricks.com/examples/DynamicPage/
But this uses hash change events. I don't want to use the hash feature, just the load content feature, but I can't seem to isolate the code for that because I think it's built into the bbq hashchange plugin.
Is there an Ajax way of doing it?
Something like
$(selector).find('#main').load('#content');
Just put a filtering selector after the URL in .load
's first argument:
$(document).ready(function() {
$("#main").load('page1.php #content');
});
That will inject the #main div in the current page with the contents of #content from page1.php.
这篇关于从外部网页内容加载到使用Ajax / jQuery的另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!