使用jQuery插件ajaxForm获取表单ID并上传进度条

我在一个页面上有几个表单,使用ajaxForm提交并显示上载进度。 每个表单都具有相同的类’.input_form’,唯一的id和隐藏的输入字段,其名称和类别为“category”,具有唯一值。 以下是最初的示例: http : //jquery.malsup.com/form/progress.html

var bar = $('.bar'); var percent = $('.percent'); var status = $('#status'); $('.input_form').ajaxForm({ beforeSend: function() { status.empty(); var percentVal = '0%'; bar.width(percentVal) percent.html(percentVal); }, uploadProgress: function(event, position, total, percentComplete) { var percentVal = percentComplete + '%'; bar.width(percentVal) percent.html(percentVal); }, complete: function(xhr) { status.html(xhr.responseText); $('#activity_feed_load').load(querybuild()); $('.wall_cat_selected').removeClass('wall_cat_selected'); $('.input_form, .arrow').hide(); var percentVal = '0%'; bar.width(percentVal) percent.html(percentVal); $('.input_form').resetForm(); } }); 

在完整的函数中,我想检索提交的表单的id或提交的表单中隐藏字段的值。 我尝试了以下哪些不起作用。

 var value = $('.input_form .category').fieldValue(); alert('The category is: ' + value[0]); 

基本上,我不确定如何为提交的表单提供($ this)。

谢谢你的帮助!

好的,我刚刚从相关的SO问题中找到了如何做到这一点:

如何在jquery ajaxform插件中使用$(this)

基本上,我只需要将以下内容添加到我的ajaxForm函数中:

 success: function(html, status, xhr, myForm) { alert(myForm.attr('id')); } 

希望这有助于其他人。

好的,我刚刚从相关的SO问题中找到了如何做到这一点:

如何在jquery ajaxform插件中使用$(this)

基本上,我只需要将以下内容添加到我的ajaxForm函数中:

 success: function(html, status, xhr, myForm) { alert(myForm.attr('id')); } 

希望这有助于其他人。