<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post//</link>
<title><![CDATA[使用prototype的Ajax.Updater更新带javascript代码]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Ajax]]></category>
<pubDate>Thu, 22 May 2008 09:52:56 +0000</pubDate> 
<guid>https://blog.liuts.com/post//</guid> 
<description>
<![CDATA[ 
	prototype的Ajax.Updater可以用来更新一段html，但在更新带javascrīpt的html时，需要注意几个问题<br/>一. 需要在Ajax.Updater添加参数 evalscrīpts : true<br/>二. javascript代码块要使用下面的形式<br/><textarea name="code" class="javascript" rows="15" cols="100">
showHi = function() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;alert('Hi');
&#125;
</textarea><br/>而不能使用下面的形式<br/><textarea name="code" class="javascript" rows="15" cols="100">
function showHi() &#123;
&nbsp;&nbsp;&nbsp;&nbsp;alert('Hi');
&#125;
</textarea><br/>三. 注意javascript代码块中不能使用 <!--&nbsp;&nbsp;//--> 标记，否则 IE 会出错，firefox没问题。<br/>下面是个例子, 在a1.jsp中加载a2.jsp：<br/>a1.jsp代码<br/><textarea name="code" class="html" rows="15" cols="100">
<html>
 <head>
 <title>Insert title here</title>
 <script type="text/javascript" src="prototype-150.js"></script>
 <script type="text/javascript">
 function ajax() &#123;
&nbsp;&nbsp;var url = "/MyWebApp/a2.jsp";
 var myajax = new Ajax.Updater(
 &#123;success: 'mydiv'&#125;,
 url,
 &#123;
&nbsp;&nbsp;asynchronous:true,
&nbsp;&nbsp;method: 'get',
&nbsp;&nbsp;evalscripts:true
 &#125;
 );
 &#125;
 </script>
 </head>
 <body>
<a href="#" onclick="ajax()">click here1</a>
<div id="mydiv"></div>
</body>
</html>
</textarea><br/>a2.jsp代码<br/><textarea name="code" class="html" rows="15" cols="100">
<script type="text/javascript">
showHi = function() &#123;
 alert('Hi');
&#125;
sayHello = function() &#123;
 alert('Hello');
&#125;
 </script>
<a href="#" onclick="showHi();">showHi</a>
<script type="text/javascript">
 sayHello();
</script>
</textarea><br/>Tags - <a href="https://blog.liuts.com/tags/prototype/" rel="tag">prototype</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post//#blogcomment</link>
<title><![CDATA[[评论] 使用prototype的Ajax.Updater更新带javascript代码]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://blog.liuts.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>