标题:一个Ajxa问题
取消只看楼主
liangwenbc
Rank: 3Rank: 3
来 自:广州
等 级:论坛游侠
帖 子:168
专家分:174
注 册:2008-6-11
结帖率:75%
已结贴  问题点数:20 回复次数:0 
一个Ajxa问题
function Ajax() {
    var m_xmlReq = false;

    if (window.ActiveXObject) {                     //判断是否IE浏览器并创建异步对象
        try {
            m_xmlReq = new ActiveXObject('Msxml2.XMLHTTP');
        }
        catch (e) {
            try {
                m_xmlReq = new ActiveXObject('Microsoft.XMLHTTP');
            }
            catch (e) { }
        }
    }
    else if (window.XMLHttpRequest) {
        m_xmlReq = new XMLHttpRequest();
    }

    this.send = function(Url, send_data, CallBack) {
        if (!m_xmlReq) {
            return;
        }
        method = "POST";
        m_xmlReq.open(method, Url, true);           //加载服务器
        if (method == 'POST') {
            m_xmlReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
        }
        m_xmlReq.onreadystatechange = function() {  //关联异步调用方法
            if (m_xmlReq.readyState == 4) {         //判断异步调用完成
                if (m_xmlReq.status == 200) {       //判断是否调用成功                    
                    CallBack(true, m_xmlReq.responseText);
                } else {
                    CallBack(false);
                }
            }
        }
        m_xmlReq.send(send_data.toString());        //发送带参数的请求
    }
}
var AjaxObject = new Ajax();
function toLogin() {
    var username = document.getElementById("txtName").value;
    var pwd = document.getElementById("txtPwd").value;
    AjaxObject.send("login.aspx", "username=" + username + "&pwd=" + pwd,
            function(succeed, responseUrl) {        //绑定回调函数
                if (succeed) {
                    var arr = responseUrl.split("|");
                    if (arr[0] == 'true') {
                        document.URL = arr[1];      //设置登录成功后跳转的URL
                    }
                    else {
                        alert("用户名或者密码错误");
                    }
                }
            }
        );
}
请问大家this.send = function(Url, send_data, CallBack)这句是什么意思,是哪部分的知识,为何我找不到相关的解释。比如 function(Url, send_data, CallBack)这句,我只查到一个“$(selector).load(url,data,callback)”,来之:http://www.
还有 CallBack(true, m_xmlReq.responseText);这句。
以上问题麻烦大家给我解释下,有相关知识链接也可以。不胜感激

搜索更多相关主题的帖子: function IE浏览器 false 
2012-02-03 18:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360358-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.331202 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved