六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 37|回复: 0

ajax简易教程3(转载)

[复制链接]

升级  63.33%

116

主题

116

主题

116

主题

举人

Rank: 3Rank: 3

积分
390
 楼主| 发表于 2013-1-29 11:37:11 | 显示全部楼层 |阅读模式
<div class="cnt">列表6:函数getReadyStateHandler()<div style="padding-right: 5px; padding-left: 4px; font-size: 13px; padding-bottom: 4px; width: 98%; padding-top: 4px; background-color: #eeeeee; border: #cccccc 1px solid;">/**//*
* Returns a function that waits for the specified XMLHttpRequest
* to complete, then passes its XML response to the given handler function.
* req - The XMLHttpRequest whose state is changing
* responseXmlHandler - Function to pass the XML response to
*/
function getReadyStateHandler(req, responseXmlHandler)
{
  
// 返回一个监听XMLHttpRequest实例的匿名函数
  return function () {
    
// 如果请求的状态是“完成”
    if (req.readyState == 4) {
      
// 检查是否成功接收了服务器响应
      if (req.status == 200) {
        
// 将载有响应信息的XML传递到处理函数
         responseXmlHandler(req.responseXML);
       }
else {
        
// 有HTTP问题发生
         alert("HTTP error: "+req.status);
       }

     }

   }

}


您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表