我想使用malsup jquery表單插件,我不能得到簡單的例子工作(http://jquery.malsup.com/form/#ajaxForm)。我在下面粘貼了我的代碼。出了什麼問題?發生的只是我收到一個警告框,上面寫着「感謝您的評論!」。沒有其他事情發生Ajax,jquery表單插件將無法正常工作
感謝,
馬克
這是ajaxtest.html文件:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="javascript/jquery.js"></script>
<script type="text/javascript" src="javascript/jquery.form.js"></script>
<script type="text/javascript">
// wait for the DOM to be loaded
$(document).ready(function() {
var options = {
target: '#output1', // target element(s) to be updated with server response
beforeSubmit: showRequest, // pre-submit callback
success: showResponse // post-submit callback
};
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
alert("Thank you for your comment!");
});
});
function showRequest(formData, jqForm, options) {
alert("calling before sending!");
return true;
}
function showResponse(responseText, statusText, xhr, $form) {
alert("this is the callback post response");
}
</script>
<script>
</script>
</head>
<body>
<form id="myForm" action="form/report.php" method="post">
Name: <input type="text" name="name" />
Comment: <textarea name="comment"></textarea>
<input type="submit" value="Submit Comment" />
<div id="output1"></div>
</form>
</body>
</html>
這是PHP文件:
你檢查過firebug控制檯是否有任何js錯誤? – 2010-02-23 15:12:24