Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.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
POST方法多次调用“第一个常规”;“提交”第二个ajax{type:';POST';,_Ajax_Spring_Spring Mvc_Model_Addattribute - Fatal编程技术网

POST方法多次调用“第一个常规”;“提交”第二个ajax{type:';POST';,

POST方法多次调用“第一个常规”;“提交”第二个ajax{type:';POST';,,ajax,spring,spring-mvc,model,addattribute,Ajax,Spring,Spring Mvc,Model,Addattribute,大家好,我需要一些帮助我创建了一个网页 div#formsContent–它具有表单,并且通过RequestWorkListController.java控制操作 div#newReqDiv–这些是从上面提交的结果,有一个5行的表,静态一次性从数据库中提取 div#pendReqDiv–同上 div#cmplReqDiv–这个div很棘手,第一次点击提交按钮,它会获取10行,有可点击的页码和10行显示,我使用的是$.ajax(对于第二篇文章,它工作正常,只是问题是新的10行集合不能取代旧的10行

大家好,我需要一些帮助我创建了一个网页

div#formsContent–它具有表单,并且通过RequestWorkListController.java控制操作

div#newReqDiv–这些是从上面提交的结果,有一个5行的表,静态一次性从数据库中提取

div#pendReqDiv–同上

div#cmplReqDiv–这个div很棘手,第一次点击提交按钮,它会获取10行,有可点击的页码和10行显示,我使用的是$.ajax(对于第二篇文章,它工作正常,只是问题是新的10行集合不能取代旧的10行集合)

SelLocCdReqCmplDao cmplDao = new SelLocCdReqCmplDao(jdbcTemplate);

int pg = ServletRequestUtils.getIntParameter(request, "pg", 1);

List<SelLocCdReqCmplModel> cmplRows = null;
cmplRows = cmplDao.execute(pg, pageSize);
int count = cmplRows.size()*10;
model.addAttribute("cmplRows", cmplRows);
model.addAttribute("pageNav", 
    pageNav.buildPageNav("#", count, pg, pageSize, pageNavTrail));
selloccdreqcpldao cmplDao=新的selloccdreqcpldao(jdbcTemplate);
intpg=ServletRequestUtils.getIntParameter(请求,“pg”,1);
列表cmplRows=null;
cmplRows=cmplDao.execute(pg,pageSize);
int count=cmplRows.size()*10;
model.addAttribute(“cmplRows”,cmplRows);
model.addAttribute(“pageNav”,
pageNav.buildPageNav(“#”,count,pg,pageSize,pageNavTrail));
这是requestWorkList.jsp——仅脚本

<script type="text/javascript">
    $(document).ready(function() {
        $("#form").submit(function() {
            $.post($(this).attr("action"), $(this)
                .serialize(), function(html) {
                $("#formsContent").replaceWith(html);
                $('html, body').animate({
                    scrollTop : $("#message").offset().top
                }, 500);
            });
            return false;
        });
        $('.page_nav a').click(function(e) {
            //alert($(this).text());
            //$('#cmplReqDiv').empty();
            $.ajax({
                type: 'POST',
                url: '<%=request.getContextPath()%>/requestWorkList?pg='
                     + $(this).text(),
                success: function(html) {
                    var showVar = '<c:out value="${cmplRows}"/>';
                    alert("The variable show is " + showVar);
                },
            });

            e.preventDefault();
        });
    });
</script>

$(文档).ready(函数(){
$(“#表单”).submit(函数(){
$.post($(this.attr(“操作”),$(this)
.serialize(),函数(html){
$(“#formsContent”)。替换为(html);
$('html,body')。设置动画({
scrollTop:$(“#消息”).offset().top
}, 500);
});
返回false;
});
$('.page_nav a')。单击(函数(e){
//警报($(this.text());
//$('#cmplReqDiv').empty();
$.ajax({
键入:“POST”,
url:“/requestWorkList?pg=”
+$(this).text(),
成功:函数(html){
var showVar='';
警报(“变量显示为”+showVar);
},
});
e、 预防默认值();
});
});

玩了一段时间后,我设法刷新了子表中的数据。我只发布了更改后的java脚本

<script type="text/javascript">
    $(document).ready(function() {
        $("#form").submit(function() {
            $.post($(this).attr("action"), $(this)
                .serialize(), function(html) {
                $("#formsContent").replaceWith(html);
                $('html, body').animate({
                    scrollTop : $("#message").offset().top
                }, 500);
            });
            return false;
        });
        $('.page_nav a').click(function(e) {
            $('#cmplReqDiv').empty();
            $.ajax({
                type: 'POST',
                serialize: $("#form").serialize(),
                url: '<%=request.getContextPath()%>/requestWorkList?pg='
                     + $(this).text(),
                success: function(html) {
                    //var showVar = '<c:out value="${cmplRows}"/>';
                    //alert("The variable show is " + showVar);
                    $("#formsContent").replaceWith(html);
                },
            });

            e.preventDefault();
        });
    });
</script>

$(文档).ready(函数(){
$(“#表单”).submit(函数(){
$.post($(this.attr(“操作”),$(this)
.serialize(),函数(html){
$(“#formsContent”)。替换为(html);
$('html,body')。设置动画({
scrollTop:$(“#消息”).offset().top
}, 500);
});
返回false;
});
$('.page_nav a')。单击(函数(e){
$('#cmplReqDiv').empty();
$.ajax({
键入:“POST”,
序列化:$(“#表单”).serialize(),
url:“/requestWorkList?pg=”
+$(this).text(),
成功:函数(html){
//var showVar='';
//警报(“变量显示为”+showVar);
$(“#formsContent”)。替换为(html);
},
});
e、 预防默认值();
});
});

请改进这篇文章的标题,以便更好地描述文章的内容,并确保正文提出了一个清晰、可回答的问题。