Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ajax调用后丢失的表单模型绑定_Jquery - Fatal编程技术网

Jquery ajax调用后丢失的表单模型绑定

Jquery ajax调用后丢失的表单模型绑定,jquery,Jquery,我在ajax调用后得到$('#form')。serialize()='': $('#continueBtn').bind('click', function () { var url = $('#form').attr('action') + setFlowEvent('continue'); $.ajax({ type : "POST", url : url, cache:false, data: $('#form

我在ajax调用后得到
$('#form')。serialize()=''

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

<div id="ajax-content">  
    <form:form id="form" modelAttribute="model" action="${actionURL}" method="post">
        <input id="field1" type="text" value="1" name="field1"></input>
        <input id="field2" type="text" value="2" name="field2"></input>
        <button id="continueBtn">continue</button>  
    </form:form> 
</div>

继续

好的,您可能想玩一下这个游戏,但我认为现在的情况是,您将响应#ajax内容嵌套在现有的#ajax内容中

所以这里有一个建议

<div id="target-area">
  <div id="ajax-content">
     ...
  </div>
</div>

通过执行上述操作,您将自动捕获按钮事件,前提是ajax响应提供相同或类似的正文内容。

您需要问一个问题。我不知道你需要什么帮助。到底是什么问题?我看不出AJAX请求后序列化表单的值是如何相关的?请求有效吗?
$(function() {
    $("#target-area").on("click", "#continueButton", function() {
        $.ajax({
                type : "POST",
                url : url,
                cache:false,
                data: $('#form').serialize(),
                dataType: "html",
                success : function(response) {
                    var newContent = $($.parseHTML(response)).find("#ajax-content");
                    $('#target-area').html(newContent);
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                    alert("error!");
                }
            });
    });
});