我正在使用表單提交。我想知道如何在表單提交後清除表單域並打印成功消息。如何在提交ajax表單後清除表單域並打印成功消息
我用 VAR選項=( clearForm:真 }
,但它沒有工作
我的代碼: -
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script>
// wait for the DOM to be loaded
$(document).ready(function() {
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
//alert("Thank you for your comment!");
});
});
</script>
</head>
<body>
<form id="myForm" name="myForm" action="comment.php" method="post" enctype="multipart/form-data">
<input type="text" name="name" />
<br />
<textarea name="comment"></textarea>
<br />
<input type="file" value="Share a Pic" name="file" id="file" />
<br />
<input type="submit" value="Submit Comment" />
</form>
</body>
你也可以使用form.reset()來清除表單域 – 2013-02-26 09:53:15