views:

48

answers:

2

So I have Jquery Ajax working real nice, but an issue I am having is in my XML if I want to bold a work or Italicize a sentence, if I do it in the XML using HTML tags it will not show up. I am pretty sure it is due to using the .text(). Any suggestions on a work around for this?

$(document).ready(function(){
   $.ajax({
    type: "GET",
    url: "xml/sites.xml",
    dataType: "xml",
    success: function(xml) {
     $(xml).find('site').each(function(){

    $(this).find('desc').each(function(){
       var brief = $(this).find('brief').text();
       var long = $(this).find('long').text();
       var url = $(this).find('url').text();
       $('<div class="brief"></div>').html(brief).appendTo('#link_'+id);

I took out the .text() and it worked but it is not showing up in IE????? does that make any sense????????????

A: 

If <brief> is meant to contain HTML, don't call .text() at all. Try simply:

var brief = $(this).find('brief');
$('<div class="brief"></div>').append(brief);
VoteyDisciple
if I do this nothing shows up in IE or safari. But works great in FF
Xtian
A: 

Have you tried the ".html()" method instead?

$(document).ready(function(){
  $.ajax({ type: "GET", url: "xml/sites.xml", dataType: "xml", success: function(xml) {
    var brief, long, url;
    $('site desc', xml).each(function(){
      var brief = $('brief', this).html();
      var long  = $('long', this).html();
      var url   = $('url', this).html();
      $('<div class="brief"></div>').html(brief).appendTo('#link_'+id);
    });
  });
});
Nothing shows up when I use .html()
Xtian