我使用jquery加载方法作为Iframe将html内容加载到我的index.html(home)内的div的替代方法,并且我得到了包含链接的静态导航栏。但是看起来像点击第一个链接时不再工作。我还有一个登录控制台的说法:jquery.load链接不工作
主线程上的同步XMLHttpRequest由于其对最终用户体验的不利影响而被弃用。如需更多帮助,请查询https://xhr.spec.whatwg.org/。
PS:begineer水平:)
这里是我的代码
HTML链接:
<ul class="dropdown-menu">
<li id="tolink1"><a href="#">SAMPLE 1</a></li>
<li id="tolink2"><a href="#">SAMPLE 2/a> </li>
<li id="tolink3"><a href="#">SAMPLE 3</a></li>
<li id="tolink4"><a href="#">SAMPLE 4</a></li>
</ul>
的Jquery:
//#loadcontent is the id of the div
$(document).on('click', '#tolink1', function(e){
$("#loadContent").load('http://localhost/impex/SAMPLE1.html');
});
$(document).on('click', '#tolink2', function(e){
$("#loadContent").load('http://localhost/impex/SAMPLE2.html');
});
$(document).on('click', '#tolink3', function(e){
$("#loadContent").load('http://localhost/impex/SAMPLE3.html');
});
$(document).on('click', '#tolink4', function(e){
$("#loadContent").load('http://localhost/impex/SAMPLE4.html');
});
你为什么使用'e.preventDefault()'? –
oppss!我只是尝试了一些我的代码,但我已经删除。 – janKvT
现在工作吗? –