Uncaught RangeError: Maximum call stack size exceeded - JQuery form submission error

Uncaught RangeError: Maximum call stack size exceeded - JQuery form submission error

我在表单外有一个输入

<input id="BrId" name="BrId" type="text" value="1">

HTML 表格-

 <form id="photoform" enctype="multipart/form-data" method="post" action="server-side-path">
    <input type="file" id="Photos" name="photo"/>
    <input type="hidden" name="VisitGuid" value="5" />
    <input type="hidden" name="HiddenBrId" id="HiddenBrId" value="" />
    <input type="submit" />

JQuery-

$('#photoform').on('submit', function (e) { 
     e.preventDefault();
     $('#HiddenBrId').val($('#BrId').val());
     $('#photoform').submit();
});

当我点击提交按钮时,没有提交表单并且控制台显示 Uncaught RangeError: Maximum call stack size exceeded

有什么帮助吗?

$('#photoform').on('submit', function (e) { 
     e.preventDefault();
     $('#HiddenBrId').val($('#BrId').val());
     // Change is here
     $('#photoform')[0].submit();
});

原因

$('#photoform').on('submit', function (e) { //S-1
. . . 
 $('#photoform').submit(); //This is the cause, it again calls  "S-1" 
});

请说明您实际想要实现的目标。

<form id="photoform" enctype="multipart/form-data" method="post" action="server-side-path">
    <input type="file" id="Photos" name="photo"/>
    <input type="hidden" name="VisitGuid" value="5" />
    <input type="hidden" name="HiddenBrId" id="HiddenBrId" value="" />
    <input type="submit" name="submit_btn" />
</form>

<script>
$('#photoform').on('submit', function (e) { 
     e.preventDefault();
     $('#HiddenBrId').val($('#BrId').val());
     // Change is here
     $('#photoform')[0].submit();
});
</script>

注意:请避免使用提交重置作为任何来自输入的nameid属性的值。