Ajax - How refresh
after submit

前端 未结 5 1365
时光说笑
时光说笑 2020-11-30 10:57

How can I refresh just part of the page (\"DIV\") after my application releases a submit? I\'m use JQuery with plugin ajaxForm. I set my target with \"divResult\", but the p

5条回答
  •  再見小時候
    2020-11-30 11:14

    To solve this using jquery I would try this;

    $(document).ready(function() {
        $("#formSearch").submit(function() {
            var options = {
                /* target:"#divResult", */
    
                success: function(html) {
                    $("#divResult").replaceWith($('#divResult', $(html)));
                },
    
                url: "http://localhost:8081/sniper/estabelecimento/pesquisar.action"
            }
    
            $(this).ajaxSubmit(options);
            return false;
        });
    });
    

    alternatively, you could get the server to return just the html that needs to be inserted into the div rather than the rest of the html document.

    I don't really know the TableSorter plugin but I do know that you will need to reinitialize your TableSorter plugin each time you reload the element. so add a line to your success function that targets your table such as

    success: function(html) {
        var resultDiv = $("#divResult").replaceWith($('#divResult',     $(html)));
    
        $('table.tablesorter', resultDiv).TableSorter();
    }
    

提交回复
热议问题