0

我正在使用 spring webflow,但在部分渲染视图状态页面时遇到了问题。在 ajax 调用之后,我总是得到$('#form').serialize() = "" 。我有下一个ajax调用:

var bindContinueButton = function () {
    $('#continueBtn').bind('click', function () {
        var url = $('#form').attr('action') + setFlowEvent('continue');
        $.ajax({
            type : "POST",
            url : url,
            cache:false,
            data: $('#form').serialize(),
            dataType: "text",
            success : function(response) {
                var newContent = $('#ajax-content', response).html();
                $('#ajax-content').html(newContent);
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                alert("error!");
            }
        });
    });
};

我已经为渲染截断了下一个jsp:

<div id="ajax-content">
    <jsp:include page="../../jsp/common/head.jsp"/>
<table class="t1">
    <tbody>
    <portlet:actionURL var="actionURL" portletMode="view">
        <portlet:param name="execution" value="${flowExecutionKey}"/>
    </portlet:actionURL>

    <form:form id="form" modelAttribute="model" action="${actionURL}" method="post">
        <jsp:include page="../../jsp/creation/popup-save-as.jsp"/>
        <jsp:include page="../../jsp/creation/documentNumber.jsp"/>
        <jsp:include page="../../jsp/creation/initialAmount.jsp"/>
        <jsp:include page="../../jsp/creation/currentAccount.jsp"/>
        <jsp:include page="../../jsp/creation/addRegularPayment.jsp"/>
        <jsp:include page="../../jsp/creation/regularPaymentFields.jsp"/>
        <jsp:include page="../../jsp/creation/otherConditions.jsp"/>
        <jsp:include page="../../jsp/creation/certification.jsp"/>
    </form:form>

    <%-- BUTTONS --%>
    <jsp:include page="../../jsp/creation/actionButtons.jsp"/>
    </tbody>
</table>
</div>

因此,当我提交表单时,我自动运行我的服务器验证器,而不是转到 ajax 回调成功函数,在$('#ajax-content').html(newContent)之后,我得到的 $('#form').serialize()。请帮我解决这个问题。谢谢

4

2 回答 2

0

在成功回调中替换您的内容后,您需要重新绑定:

 $('#continueBtn').bind('click', function(){...});
于 2013-10-15T12:45:54.293 回答
-1

我们只需要在 ajax 提交时获取输入值吗???

所以你可以像这样使用: $('input').serialize()而不是$('#form').serialize()在你的脚本中。

于 2014-01-29T09:44:17.223 回答