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:
.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
Post a Comment