更新时间:2022-12-02 08:13:34
它的工作有以下code: -
<脚本类型=文/ JavaScript的>
$(文件)。就绪(函数(){
VAR的选择= {
clearForm:真正的,
resetForm:真
};
//绑定myForm会,并提供了一个简单的回调函数
$('#myForm会)。当作ajaxForm(函数(){
//警报(感谢您发表评论!);
});
$('#myForm会)当作ajaxForm(选项)。
});
< / SCRIPT>
感谢您的帮助
I am using for form submit. I would like to know how can I clear form fields and print a success message after form submission.
I used var options = ( clearForm: true }
but it didn't work
My code :-
<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>
It worked with the following code :-
<script type="text/javascript">
$(document).ready(function() {
var options = {
clearForm: true,
resetForm: true
};
// bind 'myForm' and provide a simple callback function
$('#myForm').ajaxForm(function() {
//alert("Thank you for your comment!");
});
$('#myForm').ajaxForm(options);
});
</script>
Thanks for the help