ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 2006-12-04 | AJAX小测试

2006-12-04 | AJAX小测试

原创 Linux操作系统 作者:xyzlotus 时间:2007-12-18 09:00:37 0 删除 编辑

做了个小小的AJAX小测试..

把这二个文件放到TOMCAT的root目录下.

在浏览器打开ajaxtest.html,然后双击链接,就会刷新局部页面 :)

<!--ajaxtest.html-->

 "http://www.w3.org/TR/html4/strict.dtd">

 
 
 Developing Web Applications with Ajax - Example
 
 <!--
function ajaxRead(file){
 var xmlObj = null;
 if(window.XMLHttpRequest){
 xmlObj = new XMLHttpRequest();
 } else if(window.ActiveXObject){
 xmlObj = new ActiveXObject("Microsoft.XMLHTTP");
 } else {
 return;
 }
 xmlObj.onreadystatechange = function(){
 if(xmlObj.readyState == 4){
 updateObj('xmlObj', xmlObj.responseXML.getElementsByTagName('data')[0].firstChild.data);
 }
 }
 xmlObj.open ('GET', file, true);
 xmlObj.send ('');
 }
 function updateObj(obj, data){
 document.getElementById(obj).firstChild.data = data;
 }
 //-->
 
 
 
 

Developing Web Applications with Ajax


 

This page demonstrates the use of Asynchronous Javascript. and XML (Ajax) technology to
 update a web page's content by reading from a remote file dynamically -- no page reloading
 is required. Note that this operation does not work for users without JavaScript. enabled.


 


 This is some sample data. It is the default data for this web page.  title="View the XML data." nclick="ajaxRead('data.xml'); this.style.display='none'; return false">View XML data.
 


 

 

<!--data.xml-->



 
 This is other sample data. It is stored in an XML file and retrieved by JavaScript.
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12443821/viewspace-775/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-12-17

  • 博文量
    41
  • 访问量
    77068