0

I have the following jQuery get:

$.get("rssread.cfm?number=10", function (d) {
  $('#feedContent').append($(d).html());
});

The get works fine and what it returns is some html of unordered lists and their items and anchor tags. No big deal. I know that the html is there and properly formed because I can do

$(d).find("ul li a").each(function (i) {
  alert("text: " + $(this).text());
  alert("href: " + $(this).attr('href'));
});

and see the data in the tags (by the alert). However, I really would like to view all of the HTML in $(d) so that I can do some testing, but for the life of me I cannot figure out how to put the contents of $(d) into the div or a span tag!!

The div tag is simply:

<div id="feedContent">
</div>

And this is the part that doesn't work (as seen at the very top of my post) that I expect would (the div comes up empty every time even though I know that $(d) contains the html.

$('#feedContent').append($(d).html());

Thanks for any help in advance!

Jagd
  • 7,169
  • 22
  • 74
  • 107

2 Answers2

1

Try simply doing this, if you're sure html is returned.

$('#feedContent').append( d );
aziz punjani
  • 25,586
  • 9
  • 47
  • 56
1

The data returned by the get is basically just a (html)string.

Just append it (don't try to create a jQuery object with it).

Change:

$('#feedContent').append($(d).html());

To:

$('#feedContent').append(d);
PeeHaa
  • 71,436
  • 58
  • 190
  • 262