javascript - Clean the previous elements after load replacement data with an ajax call -
i have page , using ajax load data database. data contains html code , put code inside div called #container
. have paginator system, if click on "next" button, ajax starts again , gets html code response, , replaces code previous code inside #container
.
i have code this:
function loading_show() { $('#loading').html("<img src='images/loading.gif'/>").fadein('fast'); } function loading_hide() { $('#loading').fadeout('fast'); } function loaddata(page) { loading_show(); $.ajax({ type: "post", url: "load_data.php", data: "page=" + page, success: function(msg) { $("#container").ajaxcomplete(function(event, request, settings) { loading_hide(); $("#container").html(msg); }); } }); }
the result of ajax function html message. part of message this:
<span id="one_15" class="textzero">8002379154 - jklm representaciones y cia ltda</span>
oo. so.. if make ajax call again html this:
<span id="one_16" class="textzero">example text</span>
the problem that, if want textzero
class after loading before textzero
class preserv
previous ajax data this:
texto2 = $('.textzero').text(); <span id="one_15" class="textzero">8002379154 - jklm representaciones y cia ltda</span> <span id="one_16" class="textzero">example text</span>
question: there way clean previous elements after load replacement data ajax call?
you can call $("#container").empty()
remove child nodes container.
Comments
Post a Comment