0

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

page.html中,当我单击按钮时,唯一的内容是“工作……” click here……没有任何反应……代码有什么问题?

4

1 回答 1

2

错误是val功能。我认为您想使用text函数而不是val

$("#message").text('ajax working..');
于 2013-01-12T05:19:13.963 回答