0

I'm learning how to load and modify web content on client side without page load and postbacks.

I want to load the content of Controls/content.html into the div just like i saw on multiple exemples :

here's the div and button :

<input type="button" id="btnHtm" onclick="Content()" name="Menu" value="HtmAppear" />
<div id="htmlCont"></div>

here's the content :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
           <h4> HELO </h4>
</body>
</html>

Here's the file path :

,enter image description here

Edit : deleted other trys

Here's my fourth try :

<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />

<script language="javascript" type="text/javascript" >

$(document).ready(function content() {
    $('#htmlCont').load("Controls/content.html");
});

</script>
2
  • 1
    When you include a script for some file, you can not put code inside. You need a script separate to your code. Commented Oct 14, 2015 at 18:20
  • @alexqoliveira the script is placed inside the Header content "content1" of my aspx, and the div is place in "content3" Commented Oct 14, 2015 at 18:25

1 Answer 1

1

Your selector need a #. Try this:

<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>

<script>
    $(document).ready(function() {
       $('#htmlCont').load("Controls/content.html");
    });

</script>
Sign up to request clarification or add additional context in comments.

10 Comments

See my edit, it does not work, if you think i misunderstood the syntax, please provide a complete answer...
Sorry about that, but when you include a script for some file, you can not put code inside. You need a script separate to your code. I edited my answer.
Uncaught ReferenceError: content is not defined
try to remove the name of the function 'content'. $(document).ready(function () { $('#htmlCont').load("Controls/content.html"); });
To name a function where you need to write: jsfiddle.net/alexqoliveira/optxw1w7
|

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.