Jquery表单提交不成功?

Jquery表单提交不成功?,jquery,jqueryform,Jquery,Jqueryform,我有一个jQuery函数,如下所示: $(function(){ function unshareDialog(event) { $( "#dialog-confirm" ).dialog({ resizable: false, height:200, width: 365, modal: true, buttons: { "

我有一个jQuery函数,如下所示:

$(function(){
    function unshareDialog(event) {
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:200,
            width: 365,
            modal: true,
            buttons: {
              "Unshare": function() {
                  $('#unshare_form').submit();
              },
              Cancel: function() {
                $( this ).dialog( "close" );
              }
            }
          });
          return false;
    }
    $('#unshare_entire_file').click(unshareDialog);
});
<form action="/unshare/" id="unshare_form" method="post">
    <input type="submit" value="Unshare" name="unshare_to_user" id="unshare_to_user" />
    <input type="submit" value="Unshare" id="unshare_entire_file" 
 name="unshare_entire_file" />
</form>
if request.POST.get('unshare_entire_file'):
    ...unshare for file
else
     ..unshare for user
我的表单有两个提交按钮,如下所示:

$(function(){
    function unshareDialog(event) {
        $( "#dialog-confirm" ).dialog({
            resizable: false,
            height:200,
            width: 365,
            modal: true,
            buttons: {
              "Unshare": function() {
                  $('#unshare_form').submit();
              },
              Cancel: function() {
                $( this ).dialog( "close" );
              }
            }
          });
          return false;
    }
    $('#unshare_entire_file').click(unshareDialog);
});
<form action="/unshare/" id="unshare_form" method="post">
    <input type="submit" value="Unshare" name="unshare_to_user" id="unshare_to_user" />
    <input type="submit" value="Unshare" id="unshare_entire_file" 
 name="unshare_entire_file" />
</form>
if request.POST.get('unshare_entire_file'):
    ...unshare for file
else
     ..unshare for user

但当我使用
jQuery
提交表单时,结果证明这不起作用。我想知道哪个提交按钮被点击,并相应地进行处理。我该怎么做呢?

像这样的东西怎么样

$(function () {
    function unshareDialog(event, elem) {
        event.preventDefault();
        var input = $("<input>").attr("type", "hidden").attr("name", elem.attr("id")).val(1);
        $("#unshare_form").prepend(input);
        $("#dialog-confirm").dialog({
            resizable: false,
            height: 200,
            width: 365,
            modal: true,
            buttons: {
                "Unshare": function () {
                    $("#unshare_form").submit();
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
        return false;
    }
    $('#unshare_entire_file,#unshare_to_user').click(function (e) {
        unshareDialog(e, $(this));
    });
});
$(函数(){
函数取消共享对话框(事件,元素){
event.preventDefault();
var input=$(“”)attr(“type”,“hidden”).attr(“name”,elem.attr(“id”)).val(1);
$(“#取消共享表格”)。前置(输入);
$(“#对话框确认”)。对话框({
可调整大小:false,
身高:200,
宽度:365,
莫代尔:是的,
按钮:{
“取消共享”:函数(){
$(“#取消共享表单”).submit();
},
取消:函数(){
$(此).dialog(“关闭”);
}
}
});
返回false;
}
$(“#取消共享整个文件,#取消共享给用户”)。单击(函数(e){
取消共享对话框(e,$(this));
});
});

它显然不是最优的,但它应该可以工作

什么意思是“这不起作用”??这里你试图提交一个ID为
的表单取消共享表单
,但是你没有任何ID为的表单,这是复制代码造成的打字错误吗?@maqjav:我只复制了表单的提交按钮。我在更新的问题中包含了表单。@我的问题是:我在服务器中的函数无法识别它是取消共享整个文件还是取消共享给用户。如果我在没有jquery的情况下以正常方式提交表单,它就会工作。