javascript - Remove HTML Elements from JQuery AJAX load() Response -



javascript - Remove HTML Elements from JQuery AJAX load() Response -

is there possibility remove specific html elements ajax (load) response before placing in container? in case want remove "#containertop", including content, response.

response (html):

<html> <head></head> <body> <div id="containermain"> <div>...</div> <div id="containertop">content-to-remove-including-container-div...</div> </div> </body> </html>

i've tried this, without success.

<div id="middle"></div> <script> $( "#middle" ).load( "http://<url>", function(response, status, xhr){ $response.remove('#containertop'); }); </script>

any ideas?

.load() inserts content straight you. not give chance modify before inserted. such have 2 options:

you can modify content after inserted, before painted in .load() completion handler. you can switch .get() content data, set jquery object, modify using jquery methods, insert modified content page yourself.

here's illustration of sec option:

$.get("http://<url>", function(data) { var temp = $(data); temp.find('#containertop').remove(); $('#middle').empty().append(temp); });

javascript jquery html ajax response

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -