简体   繁体   English

Javascript / jquery从另一个页面加载特定的div

[英]Javascript/jquery Loading a specific div from another page

im trying to load a specific div from a different webpage. 我正在尝试从其他网页加载特定的div。

<div id="result">Loading</div>

<script>
        $( "#result" ).load("http://bte.gep.msess.gov.pt/pesquisa_avancada.php #boxinterior" );
        </script>

I already tried with jquery and with javascript but its not working properly, as it should. 我已经尝试过使用jquery和javascript,但是它不能正常工作,应该这样做。 Any ideias? 有什么想法吗? The #boxinterior is the div from the other website. #boxinterior是另一个网站的div。

EDIT 编辑

its not showing me the div as it should and its giving me a 它没有向我显示div,它给了我一个

XMLHttpRequest cannot load http://bte.gep.msess.gov.pt/pesquisa_avancada.php . XMLHttpRequest无法加载http://bte.gep.msess.gov.pt/pesquisa_avancada.php No 'Access-Control-Allow-Origin' header is present on the requested resource. 所请求的资源上没有“ Access-Control-Allow-Origin”标头。 Origin 'null' is therefore not allowed access. 因此,不允许访问原始“空”。

Per your edit, you aren't allowed to client-side load content from other domains for security reasons. 出于安全原因,每次编辑都不允许客户端从其他域加载内容。

If you want that content injected into your page, you should load it server side and include it with the response. 如果要将内容注入到页面中,则应在服务器端加载它并将其包含在响应中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM