找回密碼
 註冊
搜索
查看: 1685|回復: 3

[教學] javascript xmlhttp 回傳值訊息表示

[複製鏈接]
發表於 2013-6-7 17:23:47 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
The onreadystatechange eventWhen a request to a server is sent, we want to perform some actions based on the response.
The onreadystatechange event is triggered every time the readyState changes.
The readyState property holds the status of the XMLHttpRequest.
Three important properties of the XMLHttpRequest object:
Property
Description
onreadystatechangeStores a function (or the name of a function) to be called automatically each time the readyState property changes
readyStateHolds the status of the XMLHttpRequest. Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready
status200: "OK"
404: Page not found
In the onreadystatechange event, we specify what will happen when the server response is ready to be processed.
When readyState is 4 and status is 200, the response is ready:
  1. xmlhttp.onreadystatechange=function()
  2.   {
  3.   if (xmlhttp.readyState==4 && xmlhttp.status==200)
  4.     {
  5.     document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
  6.     }
  7.   }

複製代碼
 
發表於 2013-11-14 00:43:30 | 顯示全部樓層
謝謝版主啊!
版主招募中
發表於 2013-11-14 00:43:30 | 顯示全部樓層
HOHO~~~~~~  
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-4-30 21:20 , Processed in 0.024455 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表