简体   繁体   English

导入html的外部部分

[英]Import External part of html

Is it valid to import part of published HTML file to a DIV inside my local HTML file using Jquery?! 使用Jquery将部分已发布的HTML文件导入本地HTML文件中的DIV是否有效? Example: 例:

<script type="text/javascript">
    $(document).ready(function(){
        $(".import-to" ).load( "https://souqcms.s3.amazonaws.com/spring/cms/en/eg/2015/LPs/Test/Arabic_Fonts/index.html h1" );
    })
</script>

<div class="import-to"></div>

There's a cross-domain issue using Ajax. 使用Ajax存在跨域问题。 You must be sure you are accessing your files on the same http:// path without www. 您必须确定要在没有www的同一http://路径上访问文件。 (or access from http://www . and post to the same path including www.) which the browser considers as another domain when accessing via a www. (或从http:// www 。访问并发布到包含www。的相同路径),当通过www访问时浏览器将其视为另一个域。 path, so you see where the problem is. 路径,以便您查看问题出在哪里。 You are posting to a different domain and the browser blocks the flow because of the origin issue. 您正在发布到另一个域,并且由于起源问题,浏览器阻止了流量。

If the API is not placed on the same host that you are requesting from, the flow is blocked, and you will need to find another way to communicate with the API. 如果API不在您请求的同一主机上,则该流程将被阻止,您将需要寻找另一种与API进行通信的方式。

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

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