Working with JSON is quite new to me, yet I already like it. But i'm facing an annoying issue. Here's how things work: jquery makes an Ajax request for a specific url, this url is a STRUTS action, and, on success, returns a specific jsp this jsp includes JSON taglib (http://www.atg.com/taglibs/json) in order to render proper JSON formatting.
Shaping communications beetween client and server gives me this : alt text http://www.freeimagehosting.net/uploads/e4a91d6251.jpg
As you can see, http headers seem fine, yet, my JSON contains hex. characters, such as '
The problem is, I'm using part of the JSON answer to output html using Jquery; I'm facing this problem creating tooltips on the fly, each and every time the ajax request is made.
Maybe my javascript code isn't made to deal well with the JSON input , so heres a bit of my code to handle this JSON answer :
var toolTip = $("<span/>").addClass("tooltip").text(article.description).hide().appendTo(rowDescriptionArticle);
As you can see, I quite basically retrieve description for each article node, and insert it using text() into my span.
Any idea what going wrong ?
There's nothing abnormal about JSON containing HTML entities — if that's part of a string that the browser is going to display, then it sounds fine.
Based on the jQuery snippet and JSON sample you posted, it looks like — in my non-jQuery-using opinion — you should be setting the html()
rather than text()
of the span, as your description
field is already HTML-encoded.