treehouse : what would you like to learn today?
Web Design Web Development iOS Development

in jquery html()

  • I'm accessing a webservice to get the content to my website page and that content have some
    tags.

    Instead of making a new line, html() function is printing <br /> in the middle of the string.
    Is there any other function to deal with html tags like it should?
  • I'm not really sure what you mean. Could you explain a bit more clearly?
  • I believe what he is saying is that he's getting some content from an external webservice and it contains html elements.

    However, when outputting the content to the page using $(element).html(content); the html elements are outputted as is, instead of actually putting a line break in the content.

    Am I right?
  • That's right. Sorry for the bad explanation, my English didn't allowed a better one. :)

    I tried $(element).text(content) too but the output is:

    bla bla&lt;br /&gt;bla bla


    My file is encoded with utf-8 and when I make the request I'm using:
    req.setRequestHeader("Content-Type", "text/xml;charset=utf-8");

    Any idea?
  • Hmmm, why don't you try using jQuery to get the requests?