function ajax(url,fnsucc,fnFaild){
    if(window.XMLHttpRequest){
                var oAjax = new XMLHttpRequest();
            }
            else{
                var oAjax = new ActiveXObject("Microsoft.XMLHTTP");
            }
            //alert(oAjax);
            //2.连接到服务器;
            //open(方法,文件名,异步同步传输)
            oAjax.open('get',url+"?date="+new Date().getTime(),true);

            //3.发送请求;
            oAjax.send();

            //4.接收返回;
            oAjax.onreadystatechange = function(){
                if(oAjax.readyState==4){
                    if(oAjax.status==200){
                        fnsucc(oAjax.responseText);
                    }
                    else{
                        if(fnFaild){
                            fnFaild(oAjax.status);
                        }    
                    }
                }

            }
}

 

posted on 2015-02-05 16:45  jak、k  阅读(222)  评论(0编辑  收藏  举报