Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery post,清除此表单_Jquery_Post_This - Fatal编程技术网

jquery post,清除此表单

jquery post,清除此表单,jquery,post,this,Jquery,Post,This,我这里有一个JSFIDLE- $(函数(){ $('button')。在('click')上,函数(e){ e、 预防默认值(); e、 停止传播(); $.post(TheAjax.ajaxurl,classData).done(函数(结果){ 如果(结果=‘成功’){ $('.classForm[type=text]',this.val(''); $(“.class表单消息”).append(“谢谢””); } }"jsonp",; } }) }) }) 我在一个页面上有许多单独的表单

我这里有一个JSFIDLE-

$(函数(){
$('button')。在('click')上,函数(e){
e、 预防默认值();
e、 停止传播();
$.post(TheAjax.ajaxurl,classData).done(函数(结果){
如果(结果=‘成功’){
$('.classForm[type=text]',this.val('');
$(“.class表单消息”).append(“谢谢”

”); } }"jsonp",; } }) }) })
我在一个页面上有许多单独的表单,这些表单将部分预先填充

表单经过验证,然后我使用post将数据发送到php邮件函数

当结果是成功时,我只想清空已填写的表格


清空表单的函数来自post函数,我不能只清空“this”表单

使用
提交
事件,而不是
单击
事件。然后处理程序中的
这个
将是
表单
。将处理程序中对表单的引用保存到变量:

var form = $(this);
因为在post
success
中,此
窗口
对象。然后使用变量
form
success
中的表单为目标

$('.classForm:text', form).val('');
$('.classForm:text', form).val('');