开发者

display jquery returned data correctly

i've been a prototype user for a few years, and now for several reasons, i'm moving to jquery.. but still have yet familiarize myself with jquery's syntax.. my question is

how do I convert this prototype code to jquery correctly?

new Ajax.Updater('displayArea', 'shoutbox.php', { method:'post',
    parameters: {action: 'display', some_data: some_data}
});

and here's what i did:

$.post("shoutbox.php", {action: "display", some_data: some_data}, function(data){$("#displayArea").text(data);},"html");

i got the exact return result from jquery and prototype, but the problem is, when jquery updates the "displayArea", it's开发者_如何转开发 not quite what I expected. the returned data has some html codes in it, and instead of displaying a new line for the html tag 'br', jquery just display the 'br' in plain text. what i means is it's displaying html codes, and that's not what I want. hope you all get what i meant....

thanks


jQuery.text() method as its name implies, is used to insert a text, not HTML code. Use jQuery.html() instead.

$("#displayArea").html(data);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜