qianbao

文采有限,写不出系统的文章....所以只能记录一些小小的知识点
没有真正的捷径能绕过黑暗直达黎明..

AJAX基础模型

<script type="text/javascript">
        
var xmlHttp;
        
function createXMLHttpRequest()
        {
            
if(window.ActiveXObject)
            {
                xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
            }
            
else if(window.XMLHttpRequest)
            {
                xmlHttp 
= new XMLHttpRequest();
            }
        }
        
function startRequest()
        {
            createXMLHttpRequest();
            xmlHttp.onreadystatechange 
= handleStateChange;
            xmlHttp.open(
"GET","person.xml",true);
            xmlHttp.send(
null);
        }
        
function handleStateChange()
        {
            
if(xmlHttp.readyState==4)
            {
                
if(xmlHttp.status==200)
                {
                    alert(
"来自服务器的响应:"+xmlHttp.responseText);
                }
                
else
                {
                    alert(
"aaaa");
                }
            }
        }
    
</script>

posted on 2008-05-12 16:02 qianbao 阅读(12) 评论(0)  编辑 收藏 所属分类: Javascript And Ajax