简体   繁体   中英

How to extract HTML() of a given DIV from html() when content is coming through AJAX

i am using jquery ajax to load a section of page with another page content/html. \\

$(function() {
   app.xhr = $.ajax({
                                    url: url, 
                                    dataType: "html", 
                                    cache: false,
                                    success : function(html)
                                        {
                                            app.html = $(html);
                                            setTimeout(function(){
                                                app.insertPageData();
                                                app.xhr = null;
                                            },100)

                                        },
                                    error : function()
                                        {
                                            alert("Not Found")
                                        }
                                })


insertPageData : function()
                        {

                           $('div.data').html(app.html.find(".content").html())

                        }
});

So here is the problem specific to IE. app.html contains the HTML of the page and i need to extract one specific div html from the page which is not working with IE.

is there any other way to extract HTML from HTML??

Thanks / Gursimron

Do you have an id or class on the div you want? Also, by extract do you mean that's all you want, or do you mean that you want to remove it from the HTML?

If you want to remove the the div, and assuming you have an id, you can do this:

app.html.remove('#id-of-div');

If all you want is just the div and nothing else, then you would do this:

app.html = app.html.find('#id-of-div');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM