欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
簡(jiǎn)單ajax實(shí)例,最具兼容性,簡(jiǎn)單介紹ajax運行模式,根據此自認為最好的模式可以設計出很好的應用。
簡(jiǎn)單ajax實(shí)例,最具兼容性,簡(jiǎn)單介紹ajax運行模式,根據此自認為最好的模式可以設計出很好的應用。

asycn.txt文檔

Hello client!





async.html文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html>

  <head>

    <title>AJAX Foundations: Using XMLHttpRequest</title>

    <script type="text/javascript" src="async.js"></script>

  </head>

  <body onload="process()">

    Hello, server!



    <br/>

    <div id="myDivElement" />

  </body>

</html>





async.js文件

// holds an instance of XMLHttpRequest

//建立一個(gè)XmlHttpRequestObject對象實(shí)例

var xmlHttp = createXmlHttpRequestObject();



// creates an XMLHttpRequest instance

//建立XmlHttpRequestObject對象

function createXmlHttpRequestObject()

{

  // will store the reference to the XMLHttpRequest object

  //用于存儲XmlHttpRequest對象的引用

  var xmlHttp;

  // this should work for all browsers except IE6 and older

  //創(chuàng )建除了ie6 或者其更早版本外的所有瀏覽器

  //(用try catch結構是我見(jiàn)過(guò)最好的最具兼容性的創(chuàng )建XMLHttpRequest對象實(shí)例的方法)

  try

  {

    // try to create XMLHttpRequest object

    xmlHttp = new XMLHttpRequest();

  }

  catch(e)

  {

    // assume IE6 or older

         //假設是ie6 或其更早版本

    var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",

                                    "MSXML2.XMLHTTP.5.0",

                                    "MSXML2.XMLHTTP.4.0",

                                    "MSXML2.XMLHTTP.3.0",

                                    "MSXML2.XMLHTTP",

                                    "Microsoft.XMLHTTP");

    // try every prog id until one works

         //順序嘗試創(chuàng )建每一個(gè)對象,直到成功為止

    for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)

    {

      try

      {

        // try to create XMLHttpRequest object

                   //嘗試創(chuàng )建XMLHttpRequest對象

        xmlHttp = new ActiveXObject(XmlHttpVersions[i]);

      }

      catch (e) {}

    }

  }

  // return the created object or display an error message

  //返回已經(jīng)創(chuàng )建的對象,或顯示錯誤信息

  //實(shí)際應用中這里最好不要把錯誤信息發(fā)送到客戶(hù)端

  if (!xmlHttp)

    alert("Error creating the XMLHttpRequest object.");

  else

    return xmlHttp;

}





// called to read a file from the server

// 創(chuàng )建process()函數,讀取服務(wù)器上的回顯文本

function process()

{

  // only continue if xmlHttp isn't void

  // 當 xmlHttp不為空時(shí)繼續

  if (xmlHttp)

  {

    // try to connect to the server

         //嘗試連接服務(wù)器

    try

    {

      // initiate reading the async.txt file from the server

           //開(kāi)始讀取服務(wù)器上的async.txt文件,也可以是http://www.a.com/index.php?app=ajax&act=response

      xmlHttp.open("GET", "async.txt", true);                                              //在這里只是設置,發(fā)送。設置get方法提交的request參數,像是在地址欄中輸入http://async.txt,調用方法用異步(或者解釋成設置異步讀取的文件async.txt)

      xmlHttp.onreadystatechange = handleRequestStateChange; //設置XMLHttpRequest處理狀態(tài)變化的函數。

      xmlHttp.send(null);                                                                                     //把以上設置發(fā)送到服務(wù)器,get方法直接在以上的open方法設置提交參數,如果為post,設置send(app=ajax&act=response)

    }

    // display the error in case of failure

         //如果出現異常,顯示錯誤信息

    catch (e)



    {

      alert("Can't connect to server:\n" + e.toString());

    }

  }

}



// function that handles the HTTP response

//處理http響應的函數

function handleRequestStateChange()

{

  // obtain a reference to the <div> element on the page

  //獲取頁(yè)面上<div>元素的id

  myDiv = document.getElementById("myDivElement");

  // display the status of the request

  //依次顯示請求狀態(tài)信息

  if (xmlHttp.readyState == 1)

  {

    myDiv.innerHTML += "Request status: 1 (loading) <br/>";

  }

  else if (xmlHttp.readyState == 2)

  {

    myDiv.innerHTML += "Request status: 2 (loaded) <br/>";

  }

  else if (xmlHttp.readyState == 3)

  {

    myDiv.innerHTML += "Request status: 3 (interactive) <br/>";

  }

  // when readyState is 4, we also read the server response

  //當轉換到狀態(tài)4時(shí),讀取服務(wù)器的響應

  else if (xmlHttp.readyState == 4)

  {

    // continue only if HTTP status is "OK"

         //       xmlHttp.status為200時(shí)表示處理成功

    if (xmlHttp.status == 200)

    {

      try

      {

        // read the message from the server

                   //讀取服務(wù)器信息

        response = xmlHttp.responseText;

        // display the message

                   //顯示信息到指定id

        myDiv.innerHTML +=

                      "Request status: 4 (complete). Server said said: <br/>";

        myDiv.innerHTML += response;

      }

      catch(e)

      {

        // display error message

        alert("Error reading the response: " + e.toString());

      }

    }

    else

    {

      // display status message

      alert("There was a problem retrieving the data:\n" +

            xmlHttp.statusText);

    }

  }

}
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
AJAX 教程
ajax初步學(xué)習二
Php
一份老外寫(xiě)的XMLHttpRequest代碼多瀏覽器支持兼容性
完全了解AJAX
傳智播客:Ajax五步法 - habernate的日志 - 網(wǎng)易博客
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久