开发者

How to decode JSONP data with jQuery?

I have some data that I'm retrieving using JSONP from a remote server. The content contains HTML and I need to make it开发者_Go百科 so the characters render properly instead of printing the tags out. For example, if something has bold tags, it should just appear bold and not have the strong tags around it.

This needs to be done in JavaScript/jQuery. Just about everything I've found in search results uses some type of server side code.


If you read http://en.wikipedia.org/wiki/JSONP you can understand that you need to wrap you content into a Javascript function such as:

remoteScripts.js:

function getContent(){
    return 'YOUR HTML CONTENT';
}

and so in your HTML page you can do via JQuery:

$('YOUR ELEMENT').html(getContent());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜