I am using the following code in index.html
<html>
<head>
<title>Ajax check</title>
<script type="text/javascript" src="jquery-1.8.3.min.js" />
<script type="text/javascript">
$(document).ready(function(){
alert('working...');
$('#ibutton').click(function(e){
e.preventDefault();
alert('double click');
$.ajax({
url: "page.html",
cache: false,
success: function(){
$("#message").val('ajax working..');
},
error: function(){
$("#message").val('error in the page');
}
});
});
});
</script>
</head>
<body>
<form action="page.html">
<input type="button" id="ibutton" value="click here"/>
<div id="message"></div>
</form>
</body>
</html>
In page.html, the only content is ‘working…’
when I click the click here button… nothing happens.. what is wrong in the code?
The bug is the
valfunction. I think that you want to usetextfunction instead ofval: