0

I'm using a simple .load() function from Jquery and I can't seem to make it work. Nothing happens when I click my DIV. My alert TEST does work.

<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>

the page content.html just has the following:

<html>TEST TEST TEST</html>

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

Any ideas

3
  • It works alright to me, except that content.html isnt found. I see an error in the network log on developer tools. It tries to load content.html but the file isnt found. You might want to check the location of the content.html Commented Oct 31, 2016 at 6:20
  • @Sreekanth the content.html file is not correct ont he JS fiddle, but I am developping on my machine and the content.html is there, on the same folder as the code above Commented Oct 31, 2016 at 6:21
  • The file will be loaded relative to the path of the page. That means you either need to put it in the same folder as the page or adjust the path string accordingly. Commented Oct 31, 2016 at 6:28

2 Answers 2

1

you are loading the model using either file:// or C:/, which stays true to the error message as they are not http://

So you can either install a webserver in your local PC or upload the model somewhere else and use jsonp and change the url to http://example.com/path/to/model

Answer taken from HERE

Sign up to request clarification or add additional context in comments.

1 Comment

ahhh, you're right... I tried it on a server and it works... I didn't know it couldn't work on my machine. thanks
0

try this:

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

1 Comment

@Sreekanth I have just the HTML tag, and I tried with the body tag. Like this; <html><body>aaaaaaa</body></html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.