Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use jQuery .get() to get html content

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?

like image 961
Joe Yan Avatar asked Dec 03 '25 19:12

Joe Yan


2 Answers

.load('chk_vga.aspx #vga', function(data) {
    alert(data);
});
like image 86
d_ethier Avatar answered Dec 05 '25 12:12

d_ethier


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);
});
like image 30
epascarello Avatar answered Dec 05 '25 12:12

epascarello



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!