AJAX 绠€浠婞/h1>

AJAX 鏄紑鍙戣€呯殑姊︽兂锛屽洜涓烘偍鑳藉锛欬/p>

  • 涓嶅埛鏂伴〉闈㈡洿鏂扮綉椤袋/li>
  • 鍦ㄩ〉闈㈠姞杞藉悗浠庢湇鍔″櫒璇锋眰鏁版嵁
  • 鍦ㄩ〉闈㈠姞杞藉悗浠庢湇鍔″櫒鎺ユ敹鏁版嵁
  • 鍦ㄥ悗鍙板悜鏈嶅姟鍣ㄥ彂閫佹暟鎹?/li>

AJAX 瀹炰緥

鍗曞嚮涓嬮潰鐨勬寜閽紝璁 Ajax 鏀瑰彉杩欐鏂囨湰锛欬/h3>

浜茶嚜璇曚竴璇旤/a>

AJAX 瀹炰緥瑙i噴

HTML 椤甸潰

<!DOCTYPE html>
<html>
<body>
<div id="demo">
  <h2>璁 AJAX 鏇存敼杩欐鏂囨湰</h2>
  <button type="button" onclick="loadDoc()">鏇存敼鏂囨湰</button>
</div>
</body>
</html> 

杩欏紶 HTML 椤甸潰鍖呭惈涓€涓 <div> 鍜屼竴涓 <button>銆侟/p>

<div> 鐢ㄤ簬鏄剧ず鏉ヨ嚜鏈嶅姟鍣ㄧ殑淇℃伅銆侟/p>

<button> 璋冪敤鍑芥暟锛堝綋瀹冭鐐瑰嚮锛夈€侟/p>

璇ュ嚱鏁颁粠 web 鏈嶅姟鍣ㄨ姹傛暟鎹苟鏄剧ず瀹冿細

Function loadDoc()
function loadDoc() {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
     document.getElementById("demo").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "ajax_info.txt", true);
  xhttp.send();
} 

浠€涔堟槸 AJAX锛烖/h2>

AJAX = Asynchronous JavaScript And XML.

AJAX 骞堕潪缂栫▼璇█銆侟/p>

AJAX 浠呬粎缁勫悎浜嗭細

  • 娴忚鍣ㄥ唴寤虹殑 XMLHttpRequest 瀵硅薄锛堜粠 web 鏈嶅姟鍣ㄨ姹傛暟鎹級
  • JavaScript 鍜 HTML DOM锛堟樉绀烘垨浣跨敤鏁版嵁锛堻/li>

Ajax 鏄竴涓护浜鸿瀵肩殑鍚嶇О銆侫jax 搴旂敤绋嬪簭鍙兘浣跨敤 XML 鏉ヤ紶杈撴暟鎹紝浣嗗皢鏁版嵁浣滀负绾枃鏈垨 JSON 鏂囨湰浼犺緭涔熷悓鏍峰父瑙併€侟/p>

Ajax 鍏佽閫氳繃涓庡満鏅悗闈㈢殑 Web 鏈嶅姟鍣ㄤ氦鎹㈡暟鎹潵寮傛鏇存柊缃戦〉銆傝繖鎰忓懗鐫€鍙互鏇存柊缃戦〉鐨勯儴鍒嗭紝鑰屼笉闇€瑕侀噸鏂板姞杞芥暣涓〉闈€侟/p>

AJAX 濡備綍宸ヤ綔

AJAX
  1. 缃戦〉涓彂鐢熶竴涓簨浠讹紙椤甸潰鍔犺浇銆佹寜閽偣鍑伙級
  2. 鐢 JavaScript 鍒涘缓 XMLHttpRequest 瀵硅薄
  3. XMLHttpRequest 瀵硅薄鍚 web 鏈嶅姟鍣ㄥ彂閫佽姹侟/li>
  4. 鏈嶅姟鍣ㄥ鐞嗚璇锋眰
  5. 鏈嶅姟鍣ㄥ皢鍝嶅簲鍙戦€佸洖缃戦〉
  6. 鐢 JavaScript 璇诲彇鍝嶅簲
  7. 鐢 JavaScript 鎵ц姝g‘鐨勫姩浣滐紙姣斿鏇存柊椤甸潰锛堻/li>