1 原生j**ascript實現ajax請求 參見w3c "值得注意的是寫請求路徑是:一定不需要加 / 「
2 jquery實現ajax互動
$.ajax( )
functionfun2() ,success:function(data)
});}
$.get("請求路徑","請求引數{}","**函式","返回資料的格式")
$.post("請求路徑","請求引數{}","**函式","返回資料的格式")
**函式:
返回資料的格式:可能的型別:"xml" "html" "text" "script" "json" "jsonp"
functionfun3() ,function
(data) ,
"json"
}
原生態ajax和jquery實現ajax
js原生版實現 1 建立xmlhttprequest物件 2 然後用這個物件操作open 方法 即 xmlhttprequest.open post url,true 3 用這個物件操作onreadystatechange這個屬性 即xmlhttprequest.onreadystatechange...
原生Ajax與jQuery中的ajax操作
一.基本實現 1.建立xmlhttprequest物件 現代瀏覽器基本都內建了xmlhttprequest物件,若要相容低版本瀏覽器 ie5,ie6等 則需要對其做相容處理 2.建立狀態監聽處理function readystatechangehandle ajax響應狀態碼 具體參考ajax請求時...
原生Ajax與jQuery的Ajax和偽Ajax
用原生的ajax傳送請求var xhr new xmlhttprequest xhr.open 請求方式 post get 請求url true xhr.onreadystatechange function xhr.send 傳送的資料 用jquery的ajax傳送請求 ajax 用偽ajax如果...