Unable to use jquery .get () to get html content

advertisements

I want to get the html content of another page, so i use the following jquery .get() function

$.get("chk_vga.aspx", function(data) {
    alert($('#vga').html());
});

in the "chk_vga.aspx" page, it only have one value

<html>
    <body>
        <div id="vga">F</div>
    </body>
</html>

how can my jquery function get the "F" value?


To access the content you need to add it to an element.

$.get("chk_vga.aspx", function(data) {
    var foo = jQuery("<div></div>").html(data).find("#vga").html();
    alert(foo);
});