﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-轮上飞-随笔分类-&lt;b&gt;JAVASCRIPT&lt;/b&gt;</title><link>http://www.blogjava.net/zhyiwww/category/21210.html</link><description>zhyiwww</description><language>zh-cn</language><lastBuildDate>Sun, 03 Jun 2007 22:07:55 GMT</lastBuildDate><pubDate>Sun, 03 Jun 2007 22:07:55 GMT</pubDate><ttl>60</ttl><item><title>AJAX(Javascript)解析xml简略总结</title><link>http://www.blogjava.net/zhyiwww/archive/2007/05/29/120741.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 29 May 2007 09:55:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2007/05/29/120741.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/120741.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2007/05/29/120741.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/120741.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/120741.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal">
				<span style="font-family: 宋体;">首先，通过</span>
				<span lang="EN-US">ajax</span>
				<span style="font-family: 宋体;">向</span>
				<span lang="EN-US">url</span>
				<span style="font-family: 宋体;">提交请求，来取得远程</span>
				<span lang="EN-US">xml</span>
				<span style="font-family: 宋体;">数据。</span>
		</p>
		<p class="MsoNormal">
				<b>
						<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 200);" lang="EN-US">var</span>
				</b>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> xmlDoc = response.responseXML;<span style=""></span><o:p></o:p></span>
		</p>
		<p class="MsoNormal">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">此时，你得到了</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">xml</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">的文档对象。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">那么你如何解析文档呢？</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">也就是，如何取得一个结点对象呢？</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<b>
						<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 200);" lang="EN-US">var</span>
				</b>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> allPoi = xmlDoc.selectNodes(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">"/schemes/scheme/line/stops/stop/points/point"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">通过</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">selectNodes</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">方法，我们可以得到所有的符合这个路径的所有子节点。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">如果allPoi得到的是叶子节点的话，那么我们就可以通过<font color="#ff1493"><b><font size="4">allPoi[0].text</font></b><font size="2"><font color="#000000">来取得节点的值.</font></font></font><br /></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">下面，我们就可以遍历其对象了：</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">    </span>
				</span>
				<b>
						<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 200);" lang="EN-US">for</span>
				</b>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">(</span>
				<b>
						<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 0, 200);" lang="EN-US">var</span>
				</b>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> i=0;i&lt;pois.</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 100, 200);" lang="EN-US">length</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">;i++){</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">       </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(0, 100, 200);" lang="EN-US">alert</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">(pois[i].selectSingleNode(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">"iLongitude"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">).text);<span style="">       </span></span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">selectSingleNode</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">可以取得其中一个子节点，通过</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">text</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">属性来取得其对应的字符串值。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">取得文档后，我们解析</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">xml</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">的时候也可以通过其他的方法，比如：</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">var stopsGroup = xmlDoc.getElementsByTagName("stops")<o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">这种办法也一样可以取到你想要取得所有某节点对象。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: 宋体; color: black;">之后，你就可以通过和上面相同的方法来遍历。以进一步取得其子节点的值。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
<img src ="http://www.blogjava.net/zhyiwww/aggbug/120741.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2007-05-29 17:55 <a href="http://www.blogjava.net/zhyiwww/archive/2007/05/29/120741.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX中从远程URL动态取得xml的方法</title><link>http://www.blogjava.net/zhyiwww/archive/2007/05/14/117369.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Mon, 14 May 2007 08:28:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2007/05/14/117369.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/117369.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2007/05/14/117369.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/117369.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/117369.html</trackback:ping><description><![CDATA[
		<h2 style="text-align: center;" align="center">
				<span style="color: blue;" lang="EN-US">AJAX</span>
				<span style="font-family: 黑体; color: blue;">中从远程</span>
				<span style="color: blue;" lang="EN-US">URL</span>
				<span style="font-family: 黑体; color: blue;">动态取得</span>
				<span style="color: blue;" lang="EN-US">xml</span>
				<span style="font-family: 黑体; color: blue;">的方法</span>
				<span style="color: blue;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</h2>
		<p class="MsoPlainText">
				<b style="">
						<span style="font-size: 12pt; font-family: 黑体;">需求：<span lang="EN-US"><o:p></o:p></span></span>
				</b>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;">在<span lang="EN-US">JavaScript</span>中动态的从一个<span lang="EN-US">URL</span>取得<span lang="EN-US">xml</span>文件，然后，动态的更新数据。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<b style="">
						<span style="font-size: 12pt; font-family: 黑体;">问题的难点：<span lang="EN-US"><o:p></o:p></span></span>
				</b>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;" lang="EN-US">Javascript</span>
				<span style="color: green;">不能实现从一个<span lang="EN-US">URL</span>读取<span lang="EN-US">xml</span>数据。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;">使用动态的参数的时候，如后使用<span lang="EN-US">GET</span>方法，那么，参数有可能太长。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<b style="">
						<span style="font-size: 12pt; font-family: 黑体;">解决的办法：<span lang="EN-US"><o:p></o:p></span></span>
				</b>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;">这个办法使用<span lang="EN-US">AJAX</span>可以实现。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;">因为<span lang="EN-US">AJAX</span>可以从<span lang="EN-US">URL</span>来动态的读取<span lang="EN-US">xml</span>数据。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;">同时也可以很方便的分析和处理<span lang="EN-US">XML</span>数据。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<b style="">
						<span style="font-size: 12pt; font-family: 黑体;">问题的关键点：<span lang="EN-US"><o:p></o:p></span></span>
				</b>
		</p>
		<p class="MsoPlainText">
				<span style="color: green;" lang="EN-US">AJAX</span>
				<span style="color: green;">不能从一个不同<span lang="EN-US">Context</span>的服务器上来读入<span lang="EN-US">XML,</span>所以要想读取<span lang="EN-US">xml</span>数据的话，那就一定要在同一个<span lang="EN-US">Context</span>中，如果不在，那么就使用一个<span lang="EN-US">Servlet</span>来实现从一个远程的<span lang="EN-US">URL</span>上读取数据，然后可以通过调用此<span lang="EN-US">Servlet</span>来取得远程的数据。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<b style="">
						<span style="font-size: 12pt; font-family: 黑体;">我的实现：<span lang="EN-US"><o:p></o:p></span></span>
				</b>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style=""> </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style=""> </span>
				</span>
				<span style="">写一个<span lang="EN-US">Servlet</span>来实现从远程<span lang="EN-US">url</span>上读取<span lang="EN-US">xml</span>数据，这个<span lang="EN-US">url</span>参数是用户根据自己的需要传递的。<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">    </span>public void
doGet(HttpServletRequest request, HttpServletResponse response)<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>throws
ServletException, IOException {<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>System.out.println("
--------------<span style="">  </span>Get ----------------<span style="">  </span>");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>response.setContentType("text/xml");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>response.setCharacterEncoding("UTF-8");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>//<span style="">      </span>PrintWriter out = response.getWriter();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>//doPost(request,response);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>String
url = request.getParameter("url");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>//out.println(url);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>//String
url = "";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>System.out.println("url
is :<span style="">  </span>" + url);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>//response.setContentType("text/xml");<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>PrintWriter
out = response.getWriter();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>BufferedReader
reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()));<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>StringBuffer
xmlData = new StringBuffer();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>String
tmp = "";<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>while((tmp
= reader.readLine())!=null){<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>log.info(tmp);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>out.print(tmp);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>//System.out.println("
tmp :<span style="">  </span>" + tmp);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>xmlData.append(tmp);<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>try {<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>out.println(XMLUtil.format(xmlData.toString()));<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>} catch
(DocumentException e) {<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>//
TODO Auto-generated catch block<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">            </span>e.printStackTrace();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>reader.close();<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">        </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style="">    </span>}<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="" lang="EN-US">
						<span style=""> </span>
						<span style="">   </span>
				</span>
				<span style="">在<span lang="EN-US">AJAX</span>来调用<span lang="EN-US">servlet</span>取得此数据<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">       </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">&lt;</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);" lang="EN-US">script </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 127);" lang="EN-US">type</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">=</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(42, 0, 255);" lang="EN-US">"text/javascript"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">&gt;</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p> </o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">var </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">xmlHttp=</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">new </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">ActiveXObject(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(142, 0, 255);" lang="EN-US">"Msxml2.XMLHTTP"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">//alert(xmlHttp);<span style="">    </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">这个</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">url</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">是你的</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">servlet</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">的</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">uri,</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">只能是在同一个</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">context</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">内的，否则不能调用。所以，如果需要跨服务器的话，或者需要跨</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">context</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">的话，就需要使用在本</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">context</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">上使用一个</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">servlet</span>
				<span style="font-size: 10pt; font-family: 宋体; color: rgb(63, 95, 191);">做跳转。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">
						<span style="">
						</span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 95, 191);" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">var </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">sevUrl = </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(142, 0, 255);" lang="EN-US">"../servlet/PullXmlData?url="</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">;</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>
						<span style=""> </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">下面的那个</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">url</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">参数其实是我们的远程的</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">xml</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">的数据的</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">url,</span>
				<span style="font-size: 10pt; font-family: 宋体; color: black;">因为在参数里面有等号，所以在调用之前就要通过一个处理和转换，这一步也是必须的。</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">var </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">url = sevUrl + encodeURIComponent(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(142, 0, 255);" lang="EN-US">"http://192.168.1.50:8080/remoteServer /XmlInvoke?aaa=aaa&amp;bbb=bbb
"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);<span style="">     </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">    </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>alert(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(142, 0, 255);" lang="EN-US">"url :<span style="">  </span>" </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">+ url);<span style="">      </span><o:p></o:p></span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">    </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>xmlHttp.open(</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(142, 0, 255);" lang="EN-US">"post"</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">, url , </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">false</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">           </span>xmlHttp.onreadystatechange=</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">function</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">() </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">{<span style="">              </span></span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">
						<span style="">              </span>if </span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">(xmlHttp.readyState==4)
</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">{</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">
						<span style="">              </span>
						<span style="">  </span>
						<span style="">  </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">alert(xmlHttp.responseText);</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">              </span>
						<span style="">   </span>
						<span style="">
						</span>document.write(xmlHttp.responseText);</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">              </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">}</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">
						<span style="">           </span>}</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="text-align: left;" align="left">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(127, 0, 85);" lang="EN-US">
						<span style="">           </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">xmlHttp.send();<span style="">      </span><span style="">       </span></span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">
						<span style="">       </span>
				</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">&lt;/</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(63, 127, 127);" lang="EN-US">script</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">&gt;<o:p></o:p></span>
		</p>
		<p class="MsoPlainText">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">
						<span style="">       </span>
						<o:p>
						</o:p>
				</span>
		</p>
		<p class="MsoPlainText">
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">
						<span style="">       </span>
				</span>
				<span style="font-size: 10pt; color: teal;">我也刚接触</span>
				<span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: teal;" lang="EN-US">Ajax,</span>
				<span style="font-size: 10pt; color: teal;">所以也只能想到这个解决方案，如果大家有好的解决办法，还请多多指教。</span>
				<span style="" lang="EN-US">
						<o:p>
						</o:p>
				</span>
		</p>
<img src ="http://www.blogjava.net/zhyiwww/aggbug/117369.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2007-05-14 16:28 <a href="http://www.blogjava.net/zhyiwww/archive/2007/05/14/117369.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>javascript鼠标拉框（框选）的实现</title><link>http://www.blogjava.net/zhyiwww/archive/2007/04/03/108217.html</link><dc:creator>zhyiwww</dc:creator><author>zhyiwww</author><pubDate>Tue, 03 Apr 2007 08:04:00 GMT</pubDate><guid>http://www.blogjava.net/zhyiwww/archive/2007/04/03/108217.html</guid><wfw:comment>http://www.blogjava.net/zhyiwww/comments/108217.html</wfw:comment><comments>http://www.blogjava.net/zhyiwww/archive/2007/04/03/108217.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.blogjava.net/zhyiwww/comments/commentRss/108217.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/zhyiwww/services/trackbacks/108217.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: javascript实现框选，拉框。解决了拖拽拉框、矩形拉框的问题。这个功能主要用在地图的拉框放大和拉框缩小。也可以用在其它的需要拉框选择的地方。<br>也是我在做地图的拉框放大和拉框缩小的时候遇到的问题。<br>主要问题是，在鼠标移动的时候，不能响应mouseup事件。解决鼠标在移动的时候不能响应鼠标抬起事件的问题。&nbsp;&nbsp;<a href='http://www.blogjava.net/zhyiwww/archive/2007/04/03/108217.html'>阅读全文</a><img src ="http://www.blogjava.net/zhyiwww/aggbug/108217.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/zhyiwww/" target="_blank">zhyiwww</a> 2007-04-03 16:04 <a href="http://www.blogjava.net/zhyiwww/archive/2007/04/03/108217.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>