I'm having difficulty using my code:
<input id="button" type="button" value="Load"/>
<div id="content"> </div>
<script src="js/ajax.js" type="text/javascript"></script>
Using ajax: It seems to not run.
$('#button').click(function() {
$.ajax({
url: 'page.html',
success: function(data) {
$('#content').html(data);
}
});
});
page html contains <span>Hello</span>
Can anyone help me I don't know whats wrong I've tested with this and works properly:
<input type="text" onclick="$(this).hide();"/>
NOTE i have <script src="js/jquery.js" type="text/javascript"></script>
Did you link the jquery.js library ?
first load jquery library at the top of your page
Try specifying a dataType:
use the code below
<script>
$(function($) {
$('#button').click(function() {
$.get('page.html',function(data)
{
$("#content").html(data);
},"html")
});
});
</script>
have fun:)