开发者

display jquery returned data correctly

开发者 https://www.devze.com 2023-01-12 10:54 出处:网络
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

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

精彩评论

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

关注公众号