jQuery .load函数不工作

jQuery .load function not working

本文关键字:工作 函数 load jQuery      更新时间:2023-09-26

我正在使用一个简单的。load()函数从Jquery和我似乎不能使它工作。当我点击我的DIV时,什么也没有发生。我的alert TEST起作用了。

<div class="ing">CLICK HERE</div>
<div id="overlay3-content"></div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script type="text/javascript">
   $(document).on('click', '.ing', function(e){
      $("#overlay3-content").load('content.html');
    // window.alert("test");  THIS WORKS
    });
</script>

页面content.html只有以下内容:

<html>TEST TEST TEST</html>

JS FIDDLE: https://jsfiddle.net/37ukdrLf/

任何想法

您正在使用file://或C:/加载模型,这对错误消息保持真实,因为它们不是http://

所以你可以在你的本地PC上安装一个web服务器或将模型上传到其他地方并使用json并将url更改为http://example.com/path/to/model

答案取自

try this:

$(document).on('click', '.ing', function(e){  
      $( "#overlay3-content" ).load( "content.html", function() {
        alert( "Load was performed." );
      });  
    });