开发者

How to insert dynamic HTML from a URL using Javascript?

I want to be able to开发者_StackOverflow中文版 include a dynamic chunk of HTML in a page using javascript.

I wrote a servlet which returns a chunk of HTML, http://mydomain.com/dynamic.jsp It produces some HTML ( minus head, body tags ) like this:

<div>
     Current Weather : 89F
</div>

How can I get that dynamic chunk of HTML into the page using a line of Javascript?

What is the simplest way? I wonder if I need to wrap what the servlet produces in XML tags or in JSON format.


JQuery's .load() function is handy for loading data from a server, and you can dynamically put the HTML anywhere you want using the callback.

http://api.jquery.com/load/


If you want to use prototypejs, take a look here: http://www.prototypejs.org/learn/introduction-to-ajax

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜