0

I am using spring webflow and I have trouble with portial rendering of my view state page. I always get $('#form').serialize() = "" after ajax call. I have next ajax call:

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!");
            }
        });
    });
};

And I have next jsp snipped for rendering:

<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>

So when I submit form I automaticaly ran my server validator than I go to ajax callback success function and after $('#ajax-content').html(newContent) I get empty $('#form').serialize(). Please help me solve this problem. Thanks

user2486291
  • 117
  • 1
  • 2
  • 11

2 Answers2

0

After replacing your content in success callback you need re-bind:

 $('#continueBtn').bind('click', function(){...});
Mihail Zheludev
  • 166
  • 3
  • 10
-1

We need to get only input values while ajax submit right???

So you can use like this: $('input').serialize() instead of $('#form').serialize() in your script.