- 爱易网页
 
                        - 
                            AJAX教程
 
                        - 一个容易的AJAX例子 
 
                         
                    
                    
                    日期:2014-05-16  浏览次数:20697 次 
                    
                        
                         一个简单的AJAX例子
    xml 代码
    - <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?XHTML?1.0?Strict//EN" ??
 
    - ??"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">??
 
    - <html?xmlns="http://www.w3.org/1999/xhtml">??
 
    - <head>??
 
    - <title>Simple?XMLHttpRequest</title>??
 
    - ??? ??
 
    - <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",?"simpleResponse.xml",?true); ??
 
    - ????xmlHttp.send(null); ??
 
    - } ??
 
    - ??? ??
 
    - function?handleStateChange()?{ ??
 
    - ????if(xmlHttp.readyState?==?4)?{ ??
 
    - ????????if(xmlHttp.status?==?200)?{ ??
 
    - ????????????alert("The?server?replied?with:?"?+?xmlHttp.responseText); ??
 
    - ????????} ??
 
    - ??
 
    - } ??
 
    - } ??
 
    - </script>??
 
    - </head>??
 
    - ??
 
    - <body>??
 
    - ????<form?action=
 
 
                     
                    
                    
                        免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。