Ajax - How refresh <DIV> after submit Ajax - How refresh <DIV> after submit ajax ajax

Ajax - How refresh <DIV> after submit


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();}


Your problem is on the server side: you have to make a page that returns only the div you want, and then change the 'url' to match that.

Currently you're loading the full page with the AJAX call, which is why it's returning the whole page.


You can use most of the normal jquery ajax function parameters with ajaxSubmit. Just pass in a success function.

$('#formSearch').ajaxSubmit({success: function(){ /* refresh div */ }); 

See here for a more elaborate example.