鋒利的JQuery(五)

2022-07-15 02:18:06 字數 768 閱讀 3437

jquery與ajax:

load:    

load(url)   $("#restext").load("test.html")  載入所有元素

load(url selector)   $("#restext").load("test.html  .para")  載入class為para的元素

load(url,callback)  $("#restext").load("test.php",function) 使用get的方式傳送請求,並**function  

load(url,data,callback)  $("#restext").load("test.php",,function) 使用post的方式傳送資料請求,並**function  

callback,包含三個引數:responsetext(請求返回的內容)、textstatus(請求狀態,success、error、notmodified、timeout)、xmlhttprequest(物件)

$.get():

$.get(url,data,callback)  $.get("get.php",,function) 將資料以非同步方式提交,並返回html或xml資料(設定content-type)

callback,只有兩個引數:data(請求返回的內容)、textstatus(請求狀態,肯定是success),

$.get(url,data,callback,type)  $.get("get.php",,function,"json") 將資料以非同步方式提交,並返回jsonl資料

鋒利的jquery第五章

5.1 表單應用 表單標籤 表單域 表單按鈕 注意 哪些屬性應該用 attr 哪些應該用 prop prop 返回標準屬性 true false 原則1 只新增屬性名稱該屬性就會生效的用prop。原則2 只存在true false的屬性應該使用prop。如果是設定disable或者checked這些...

鋒利的JQuery(六)

ajax 可以設定beforesend error success complete等 getscript 載入js檔案 getjson 載入json檔案 each 通用的遍歷方法 serialize 將dom元素內容序列化為字串 serializearray 將dom元素內容序列化為json格式的...

鋒利的jquery學習

jquery物件是通過jquery包裝dom物件後產生的物件,是jquery獨有的。jquery物件無法使用dom物件的任何方法,dom物件也不能使用jquery物件的方法。jquery提供兩個方法將乙個jquery物件轉換成dom物件。var cr cr jquery物件 var cr cr 0 ...