无法使用jQuery按钮链接连接外部HTML文件
问题描述:
我试图使用href连接到同一目录中的HTML文件,但它给我一个错误加载页面。无法使用jQuery按钮链接连接外部HTML文件
它提供了以下错误:
XMLHttpRequest cannot load file:///C:/Users/Nadeesha/Desktop/Collect/FounderR.html. Received an invalid response. Origin 'null' is therefore not allowed access.
我能做些什么来解决这个问题?
<a data-theme="d" data-corners="false" data-role="button" href="FounderR.html">
<img src="images/icons/round/64x64/entr.gif" alt="entr" style="display: block; margin: 0 auto">
Founder
</a>
答
如果您正在使用chrome,并且我假设您是这样,那么您在使用localhost时将面临CORS问题。
生病建议您阅读本:
https://developers.google.com/storage/docs/cross-origin?hl=es
这是什么都与jQuery做?这是一个基本的HTML锚点。 – isherwood 2014-09-12 19:25:14
上面的代码将完美工作。上面给出的代码中没有Jquery的作用。您的Founder.html是否正确加载为独立文件? – Akhil 2014-09-12 19:28:59
我正在用jquery,javaScript和html构建一个SPA。最近我用id从一个段跳到另一个段,在这里我需要访问一个外部html文件,但是应用程序不允许这样做 – 2014-09-12 19:29:53