Antoine Pelletier
Antoine Pelletier

Reputation: 3316

jquery .load Function

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>

Upvotes: 0

Views: 386

Answers (1)

alexqoliveira
alexqoliveira

Reputation: 379

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>

Upvotes: 1

Related Questions