ajax -第一個例子

          1.MyHtml.html
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
          ? <head>
          ?<script type='text/javascript'>
          ??var req = null;
          ??var console = null;
          ??var READY_STATE_UNINITIALIZED = 0;
          ??var READY_STATE_LOADING = 1;
          ??var READY_STATE_LOADED = 2;
          ??var READY_STATE_INTERACTIVE = 3;
          ??var READY_STATE_COMPLETE = 4;
          ??
          ??function sendRequest(url,params,HttpMethod){
          ???if(!HttpMethod){
          ????HttpMethod = "GET";
          ???}
          ???req = initXMLHTTPRequest();
          ???if(req){
          ????req.onreadystatechange = onReadyState;
          ????req.open(HttpMethod,url,true);
          ????req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
          ????req.send(params);
          ????
          ???}
          ??}
          ??
          ??function initXMLHTTPRequest(){
          ???var xRequest = null;
          ???if(window.XMLHttpRequest){
          ????xRequest = new XMLHttpRequest();
          ???}else if(window.ActiveXObject){
          ????xRequest = new ActiveXObject("Microsoft.XMLHTTP");
          ???}
          ???return xRequest;
          ??}
          ??
          ??function onReadyState(){
          ???var ready = req.readyState;
          ???var data = null;
          ???if(ready==READY_STATE_COMPLETE){
          ????data = req.responseText;
          ???}else{
          ????data = "loading...[" + ready +"]";
          ???}
          ???toConsole(data);
          ??}
          ??
          ??function toConsole(data){
          ???if(console!=null){
          ????var newline = document.createElement("div");
          ????console.appendChild(newline);
          ????var txt = document.createTextNode(data);
          ????console.appendChild(txt);
          ???}
          ??}
          ??
          ??window.onload = function(){
          ???console = document.getElementById('console');
          ???sendRequest("data.txt");
          ??}
          ?</script>
          ? </head>
          ? ?
          ? <body>
          ? ?<DIV id ='console'></DIV>
          ? </body>
          </html>

          2.data.txt
          ?i'm ok!!!!!!!!

          posted on 2006-08-11 14:46 software5168 閱讀(430) 評論(1)  編輯  收藏 所屬分類: Java學習

          評論

          # re: ajax -第一個例子 2006-08-12 09:46 java技術

          不錯 辛苦了  回復  更多評論   

          <2006年8月>
          303112345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導航

          統計

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          收藏夾

          JAVA學習網站

          綜合

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 岑巩县| 江永县| 保亭| 七台河市| 巴彦淖尔市| 武宁县| 苗栗县| 新密市| 天柱县| 太谷县| 龙岩市| 宜黄县| 渑池县| 九江市| 绩溪县| 盘锦市| 阜南县| 长葛市| 东莞市| 临清市| 绩溪县| 绍兴市| 五家渠市| 高平市| 师宗县| 龙胜| 美姑县| 平邑县| 大同县| 黄龙县| 淮北市| 马龙县| 涿州市| 福贡县| 河西区| 怀集县| 米易县| 双峰县| 泾阳县| 弥勒县| 达州市|