欧美成人69-欧美成人aaaa免费高清-欧美成人aaa大片-欧美成人xxxx-大杳蕉伊人狼人久久一本线-大又大粗又爽又黄少妇毛片
我們的專業品牌服務商:網站建設、品牌策劃設計、網站優化、網站推廣等業務
龍誠微博
站點導航
免費建站
專業的互聯網絡解決方案、完善的售后服務體系 —— 龍誠互聯(溫州網絡公司 溫州網站建設),當前IP:
龍誠簡介
|
企業文化
|
我們的優勢
|
龍誠人
|
招兵募馬
龍誠動態
|
行業新聞
|
我們的觀點
|
公司公告
標準企業站
|
外貿商務站
|
商城門戶站
|
品牌動畫站
|
在線訂制
網站制作流程
|
建站知識
|
網站SEO優化
|
域名&空間
|
網站備案
|
下載中心
聯系方式
|
留言反饋
龍誠動態
行業新聞
我們的觀點
公司公告
建站技術
網站SEO優化
網站制作流程
產品報價
聯系電話:0577-55882408
傳真號碼:0577-55882411
聯系手機:15224122065
聯系地址:溫州市甌海站南商貿城C幢306
首頁-新聞中心-
建站技術
<p>jQuery確實是一個挺好的輕量級的JS框架,能幫助我們快速的開發JS應用,并在一定程度上改變了我們寫JavaScript代碼的習慣。</p> <p>廢話少說,直接進入正題,我們先來看一些簡單的方法,這些方法都是對jQuery.ajax()進行封裝以方便我們使用的方法,當然,如果要處理復雜的邏輯,還是需要用到jQuery.ajax()的(這個后面會說到).</p> <p><font size="4"><font color="#bb0000"><strong>1. load</strong>( url, [data], [callback] ) :載入遠程 HTML 文件代碼并插入至 DOM 中。</font></font></p> <p><strong>url </strong>(String) : 請求的HTML頁的URL地址。</p> <p><strong>data </strong>(Map) : (可選參數) 發送至服務器的 key/value 數據。</p> <p><strong>callback </strong>(Callback) : (可選參數) 請求完成時(<font color="#bb0000">不需要是success的</font>)的回調函數。</p> <p>這個方法默認使用 GET 方式來傳遞的,如果[data]參數有傳遞數據進去,就會自動轉換為POST方式的。jQuery 1.2 中,可以指定選擇符,來篩選載入的 HTML 文檔,DOM 中將僅插入篩選出的 HTML 代碼。語法形如 "url #some > selector"。</p> <p>這個方法可以很方便的動態加載一些HTML文件,例如表單。</p> <p>示例代碼:</p> <pre> $("<span style="color: rgb(139, 0, 0);">.ajax.load</span>").load("<span style="color: rgb(139, 0, 0);">http://www.cnblogs.com/yeer/archive/2009/06/10/1500682.html .post</span>",<br /> <span style="color: rgb(0, 0, 255);">function</span> (responseText, textStatus, XMLHttpRequest){<br /> <span style="color: rgb(0, 0, 255);">this</span>;<span style="color: rgb(0, 128, 0);">//在這里this指向的是當前的DOM對象,即$(".ajax.load")[0]</span> <br /> <span style="color: rgb(0, 128, 0);">//alert(responseText);//請求返回的內容</span> <span style="color: rgb(0, 128, 0);">//alert(textStatus);//請求狀態:success,error</span> <span style="color: rgb(0, 128, 0);">//alert(XMLHttpRequest);//XMLHttpRequest對象</span> });</pre> <p> </p> <div id="0kkqlfz" class="ajax load">這里將顯示結果。</div> <p><input id="btnload" type="button" value="Load" /></p> <p> </p> <p><strong><font color="#bb0000">注:</font></strong>不知道為什么URL寫絕對路徑在FF下會出錯,知道的麻煩告訴下。下面的get()和post()示例使用的是絕對路徑,所以在FF下你將會出錯并不會看到返回結果。<font color="#ff00ff">還有get()和post()示例都是跨域調用的,發現傳上來后沒辦法獲取結果,所以把運行按鈕去掉了。</font></p> <p> </p> <p><font size="4"><font color="#bb0000"><strong>2. jQuery.get</strong>( url, [data], [callback] ):使用GET方式來進行異步請求</font></font></p> <blockquote> <p>參數:</p> <p><strong>url </strong>(String) : 發送請求的URL地址.</p> <p><strong>data </strong>(Map) : (可選) 要發送給服務器的數據,以 Key/value 的鍵值對形式表示,會做為QueryString附加到請求URL中。</p> <p><strong>callback </strong>(Function) : (可選) 載入成功時回調函數(只有當Response的返回狀態是success才是調用該方法)。</p> </blockquote> <p>這是一個簡單的 GET 請求功能以取代復雜 $.ajax 。請求成功時可調用回調函數。如果需要在出錯時執行函數,請使用 $.ajax。示例代碼:</p> <pre> $.get("<span style="color: rgb(139, 0, 0);">./Ajax.aspx</span>", {Action:"<span style="color: rgb(139, 0, 0);">get</span>",Name:"<span style="color: rgb(139, 0, 0);">lulu</span>"}, <span style="color: rgb(0, 0, 255);">function</span> (data, textStatus){<br /> <span style="color: rgb(0, 128, 0);">//返回的 data 可以是 xmlDoc, jsonObj, html, text, 等等.</span> <span style="color: rgb(0, 0, 255);">this</span>; <span style="color: rgb(0, 128, 0);">// 在這里this指向的是Ajax請求的選項配置信息,請參考下圖</span> <span style="color: rgb(0, 0, 255);">alert</span>(data);<br /> <span style="color: rgb(0, 128, 0);">//alert(textStatus);//請求狀態:success,error等等。<br /> 當然這里捕捉不到error,因為error的時候根本不會運行該回調函數</span> <span style="color: rgb(0, 128, 0);">//alert(this);</span> });</pre> <p>點擊發送請求:</p> <p>jQuery.get()回調函數里面的 this ,指向的是Ajax請求的選項配置信息:</p> <p><a ><img width="466" height="289" alt="image" src="http://images.cnblogs.com/cnblogs_com/QLeelulu/WindowsLiveWriter/jQueryAjax_B934/image_thumb_1.png" border="0" style="border-width: 0px;" /></a></p> <p> </p> <p><font size="4"><font color="#bb0000"><strong>3. jQuery.post</strong>( url, [data], [callback], [type] ) :使用POST方式來進行異步請求</font></font></p> <p> </p> <blockquote> <p>參數:</p> <p><strong>url </strong>(String) : 發送請求的URL地址.</p> <p><strong>data </strong>(Map) : (可選) 要發送給服務器的數據,以 Key/value 的鍵值對形式表示。</p> <p><strong>callback </strong>(Function) : (可選) 載入成功時回調函數(只有當Response的返回狀態是success才是調用該方法)。</p> <p><strong>type</strong> (String) : (可選)官方的說明是:Type of data to be sent。其實應該為客戶端請求的類型(JSON,XML,等等)</p> </blockquote> <p>這是一個簡單的 POST 請求功能以取代復雜 $.ajax 。請求成功時可調用回調函數。如果需要在出錯時執行函數,請使用 $.ajax。示例代碼:</p> <p>Ajax.aspx:</p> <pre> Response.ContentType = "<span style="color: rgb(139, 0, 0);">application/json</span>";<br /> Response.Write("<span style="color: rgb(139, 0, 0);">{result: '</span>" + Request["<span style="color: rgb(139, 0, 0);">Name</span>"] + "<span style="color: rgb(139, 0, 0);">,你好!(這消息來自服務器)'}</span>");</pre> <p>jQuery 代碼:</p> <pre> $.post("<span style="color: rgb(139, 0, 0);">Ajax.aspx</span>", { Action: "<span style="color: rgb(139, 0, 0);">post</span>", Name: "<span style="color: rgb(139, 0, 0);">lulu</span>" },<br /> <span style="color: rgb(0, 0, 255);">function</span> (data, textStatus){<br /> <span style="color: rgb(0, 128, 0);">// data 可以是 xmlDoc, jsonObj, html, text, 等等.</span> <span style="color: rgb(0, 128, 0);">//this; // 這個Ajax請求的選項配置信息,請參考jQuery.get()說到的this</span> <span style="color: rgb(0, 0, 255);">alert</span>(data.result);<br /> }, "<span style="color: rgb(139, 0, 0);">json</span>");</pre> <p>點擊提交:</p> <p>這里設置了請求的格式為"json":</p> <p><a ><img width="440" height="125" alt="image" src="http://images.cnblogs.com/cnblogs_com/QLeelulu/WindowsLiveWriter/jQueryAjax_B934/image_thumb_2.png" border="0" style="border-width: 0px;" /></a></p> <p>如果你設置了請求的格式為"json",此時你沒有設置Response回來的ContentType 為:Response.ContentType = "application/json"; 那么你將無法捕捉到返回的數據。</p> <p>注意一下,<span style="color: rgb(0, 0, 255);">alert</span>(data.result); 由于設置了Accept報頭為“json”,這里返回的data就是一個對象,并不需要用eval()來轉換為對象。</p> <p> </p> <p><font color="#bb0000"><font size="4"><strong>4. jQuery.getScript</strong>( url, [callback] ) : 通過 GET 方式請求載入并執行一個 JavaScript 文件</font>。</font></p> <blockquote> <h4>參數</h4> <p><strong>url </strong>(String) : 待載入 JS 文件地址。</p> <p><strong>callback </strong>(Function) : (可選) 成功載入后回調函數。</p> </blockquote> <p>jQuery 1.2 版本之前,getScript 只能調用同域 JS 文件。 1.2中,您可以跨域調用 JavaScript 文件。注意:Safari 2 或更早的版本不能在全局作用域中同步執行腳本。如果通過 getScript 加入腳本,請加入延時函數。</p> <p>這個方法可以用在例如當只有編輯器focus()的時候才去加載編輯器需要的JS文件.下面看一些示例代碼:</p> <p>加載并執行 test.js。</p> <p><strong>jQuery 代碼:</strong></p> <p>$.getScript("test.js");</p> <hr /> <p>加載并執行 AjaxEvent.js ,成功后顯示信息。</p> <p><strong>jQuery 代碼:</strong></p> <pre> $.getScript("<span style="color: rgb(139, 0, 0);">AjaxEvent.js</span>", <span style="color: rgb(0, 0, 255);">function</span>(){<br /> <span style="color: rgb(0, 0, 255);">alert</span>("<span style="color: rgb(139, 0, 0);">AjaxEvent.js 加載完成并執行完成.你再點擊上面的Get或Post按鈕看看有什么不同?</span>");<br /> });</pre> <p><input id="btngetScript" type="button" value="加載并運行Ajax全局事件腳本" /> <input disabled="disabled" id="btnremoveScript" type="button" value="取消Ajax全局事件" /></p> <p>加載完后請重新點擊一下上面的 Load 請求看看有什么不同。</p> <p><font color="#bb0000" size="4"><strong>jQuery Ajax 事件</strong></font></p> <p>Ajax請求會產生若干不同的事件,我們可以訂閱這些事件并在其中處理我們的邏輯。在jQuery這里有兩種Ajax事件:局部事件 和 全局事件。</p> <p><strong>局部事件</strong>就是在每次的Ajax請求時在方法內定義的,例如:</p> <pre> $.ajax({<br /> beforeSend: <span style="color: rgb(0, 0, 255);">function</span>(){<br /> <span style="color: rgb(0, 128, 0);">// Handle the beforeSend event</span> }, complete: <span style="color: rgb(0, 0, 255);">function</span>(){<br /> <span style="color: rgb(0, 128, 0);">// Handle the complete event</span> } <span style="color: rgb(0, 128, 0);">// ...</span> });</pre> <p><strong>全局事件</strong>是每次的Ajax請求都會觸發的,它會向DOM中的所有元素廣播,在上面 getScript() 示例中加載的腳本就是全局Ajax事件。全局事件可以如下定義:</p> <pre> $("<span style="color: rgb(139, 0, 0);">#loading</span>").bind("<span style="color: rgb(139, 0, 0);">ajaxSend</span>", <span style="color: rgb(0, 0, 255);">function</span>(){<br /> $(<span style="color: rgb(0, 0, 255);">this</span>).show();<br /> }).bind("<span style="color: rgb(139, 0, 0);">ajaxComplete</span>", <span style="color: rgb(0, 0, 255);">function</span>(){<br /> $(<span style="color: rgb(0, 0, 255);">this</span>).hide();<br /> });</pre> <p>或者:</p> <pre> $("<span style="color: rgb(139, 0, 0);">#loading</span>").ajaxStart(<span style="color: rgb(0, 0, 255);">function</span>(){<br /> $(<span style="color: rgb(0, 0, 255);">this</span>).show();<br /> }); </pre> <p>我們可以在特定的請求將全局事件禁用,只要設置下 global 選項就可以了:</p> <pre> $.ajax({<br /> url: "<span style="color: rgb(139, 0, 0);">test.html</span>",<br /> global: <span style="color: rgb(0, 0, 255);">false</span>,<span style="color: rgb(0, 128, 0);">// 禁用全局Ajax事件.</span> <span style="color: rgb(0, 128, 0);">// ...</span> });</pre> <p>下面是jQuery官方給出的完整的Ajax事件列表:</p> <ul> <li><strong>ajaxStart</strong> (Global Event)<br /> This event is broadcast if an Ajax request is started and no other Ajax requests are currently running. <ul> <li><strong>beforeSend</strong> (Local Event)<br /> This event, which is triggered before an Ajax request is started, allows you to modify the XMLHttpRequest object (setting additional headers, if need be.)</li> <li><strong>ajaxSend</strong> (Global Event)<br /> This global event is also triggered before the request is run.</li> <li><strong>success</strong> (Local Event)<br /> This event is only called if the request was successful (no errors from the server, no errors with the data).</li> <li><strong>ajaxSuccess</strong> (Global Event)<br /> This event is also only called if the request was successful.</li> <li><strong>error</strong> (Local Event)<br /> This event is only called if an error occurred with the request (you can never have both an error and a success callback with a request).</li> <li><strong>ajaxError</strong> (Global Event)<br /> This global event behaves the same as the local error event.</li> <li><strong>complete</strong> (Local Event)<br /> This event is called regardless of if the request was successful, or not. You will always receive a complete callback, even for synchronous requests.</li> <li><strong>ajaxComplete</strong> (Global Event)<br /> This event behaves the same as the complete event and will be triggered every time an Ajax request finishes.</li> </ul> </li> <li><strong>ajaxStop</strong> (Global Event)<br /> This global event is triggered if there are no more Ajax requests being processed. <p>具體的全局事件請參考API文檔。<br /> 好了,下面開始說jQuery里面功能最強的Ajax請求方法 $.ajax();</p> <p> </p> <p><font size="4"><font color="#bb0000"><strong>jQuery.ajax</strong>( options ) : 通過 HTTP 請求加載遠程數據</font></font></p> <p>這個是jQuery 的底層 AJAX 實現。簡單易用的高層實現見 $.get, $.post 等。</p> <p>$.ajax() 返回其創建的 XMLHttpRequest 對象。大多數情況下你無需直接操作該對象,但特殊情況下可用于手動終止請求。</p> <p><strong>注意:</strong> 如果你指定了 dataType 選項,請確保服務器返回正確的 MIME 信息,(如 xml 返回 "text/xml")。錯誤的 MIME 類型可能導致不可預知的錯誤。見 <a ><font color="#000000">Specifying the Data Type for AJAX Requests</font></a> 。<br /> 當設置 datatype 類型為 'script' 的時候,所有的遠程(不在同一個域中)POST請求都回轉換為GET方式。</p> <p>$.ajax() 只有一個參數:參數 key/value 對象,包含各配置及回調函數信息。詳細參數選項見下。</p> <p>jQuery 1.2 中,您可以跨域加載 JSON 數據,使用時需將數據類型設置為 <a ><font color="#000000">JSONP</font></a>。使用 <a ><font color="#000000">JSONP</font></a> 形式調用函數時,如 "myurl?callback=?" jQuery 將自動替換 ? 為正確的函數名,以執行回調函數。數據類型設置為 "jsonp" 時,jQuery 將自動調用回調函數。(這個我不是很懂)</p> <p>參數列表:</p> <p> </p> <table width="600" border="1" cellspacing="2" cellpadding="2"> <tbody> <tr> <td width="90" valign="top"><font color="#bb0000">參數名</font></td> <td width="83" valign="top"><font color="#bb0000">類型</font></td> <td width="419" valign="top"><font color="#bb0000">描述</font></td> </tr> <tr> <td width="90" valign="top"><strong>url </strong></td> <td width="83" valign="top">String</td> <td width="419" valign="top">(默認: 當前頁地址) 發送請求的地址。</td> </tr> <tr> <td width="90" valign="top"><strong>type</strong></td> <td width="83" valign="top">String</td> <td width="419" valign="top">(默認: "GET") 請求方式 ("POST" 或 "GET"), 默認為 "GET"。注意:其它 HTTP 請求方法,如 PUT 和 DELETE 也可以使用,但僅部分瀏覽器支持。</td> </tr> <tr> <td width="90" valign="top"><strong>timeout</strong></td> <td width="83" valign="top">Number</td> <td width="419" valign="top">設置請求超時時間(毫秒)。此設置將覆蓋全局設置。</td> </tr> <tr> <td width="90" valign="top"><strong>async </strong></td> <td width="83" valign="top">Boolean</td> <td width="419" valign="top">(默認: true) 默認設置下,所有請求均為異步請求。如果需要發送同步請求,請將此選項設置為 false。注意,同步請求將鎖住瀏覽器,用戶其它操作必須等待請求完成才可以執行。</td> </tr> <tr> <td width="90" valign="top"><strong>beforeSend </strong></td> <td width="83" valign="top">Function</td> <td width="419" valign="top">發送請求前可修改 XMLHttpRequest 對象的函數,如添加自定義 HTTP 頭。XMLHttpRequest 對象是唯一的參數。<br /> <pre><span style="color: rgb(0, 0, 255);">function</span> (XMLHttpRequest) {<br /> <span style="color: rgb(0, 0, 255);">this</span>; <span style="color: rgb(0, 128, 0);">// the options for this ajax request</span> }</pre> </td> </tr> <tr> <td width="90" valign="top"><strong>cache </strong></td> <td width="83" valign="top">Boolean</td> <td width="419" valign="top">(默認: true) jQuery 1.2 新功能,設置為 false 將不會從瀏覽器緩存中加載請求信息。</td> </tr> <tr> <td width="90" valign="top"><strong>complete </strong></td> <td width="83" valign="top">Function</td> <td width="419" valign="top">請求完成后回調函數 (請求成功或失敗時均調用)。參數: XMLHttpRequest 對象,成功信息字符串。<br /> <pre><span style="color: rgb(0, 0, 255);">function</span> (XMLHttpRequest, textStatus) {<br /> <span style="color: rgb(0, 0, 255);">this</span>; <span style="color: rgb(0, 128, 0);">// the options for this ajax request</span> }</pre> </td> </tr> <tr> <td width="90" valign="top"><strong>contentType </strong></td> <td width="83" valign="top">String</td> <td width="419" valign="top">(默認: "application/x-www-form-urlencoded") 發送信息至服務器時內容編碼類型。默認值適合大多數應用場合。</td> </tr> <tr> <td width="90" valign="top"><strong>data </strong></td> <td width="83" valign="top">Object,<br /> String</td> <td width="419" valign="top">發送到服務器的數據。將自動轉換為請求字符串格式。GET 請求中將附加在 URL 后。查看 processData 選項說明以禁止此自動轉換。必須為 Key/Value 格式。如果為數組,jQuery 將自動為不同值對應同一個名稱。如 {foo:["bar1", "bar2"]} 轉換為 '&foo=bar1&foo=bar2'。</td> </tr> <tr> <td width="90" valign="top"><strong>dataType </strong></td> <td width="83" valign="top">String</td> <td width="419" valign="top"> <p>預期服務器返回的數據類型。如果不指定,jQuery 將自動根據 HTTP 包 MIME 信息返回 responseXML 或 responseText,并作為回調函數參數傳遞,可用值:</p> <p>"xml": 返回 XML 文檔,可用 jQuery 處理。</p> <p>"html": 返回純文本 HTML 信息;包含 script 元素。</p> <p>"script": 返回純文本 JavaScript 代碼。不會自動緩存結果。</p> <p>"json": 返回 JSON 數據 。</p> <p>"jsonp": <a >JSONP</a> 格式。使用 <a >JSONP</a> 形式調用函數時,如 "myurl?callback=?" jQuery 將自動替換 ? 為正確的函數名,以執行回調函數。</p> </td> </tr> <tr> <td width="90" valign="top"><strong>error </strong></td> <td width="83" valign="top">Function</td> <td width="419" valign="top">(默認: 自動判斷 (xml 或 html)) 請求失敗時將調用此方法。這個方法有三個參數:XMLHttpRequest 對象,錯誤信息,(可能)捕獲的錯誤對象。<br /> <pre><span style="color: rgb(0, 0, 255);">function</span> (XMLHttpRequest, textStatus, errorThrown) {<br /> <span style="color: rgb(0, 128, 0);">// 通常情況下textStatus和errorThown只有其中一個有值 </span> <span style="color: rgb(0, 0, 255);">this</span>; <span style="color: rgb(0, 128, 0);">// the options for this ajax request</span> }</pre> </td> </tr> <tr> <td width="90" valign="top"><strong>global </strong></td> <td width="83" valign="top">Boolean</td> <td width="419" valign="top">(默認: true) 是否觸發全局 AJAX 事件。設置為 false 將不會觸發全局 AJAX 事件,如 ajaxStart 或 ajaxStop 。可用于控制不同的Ajax事件</td> </tr> <tr> <td width="90" valign="top"><strong>ifModified </strong></td> <td width="83" valign="top">Boolean</td> <td width="419" valign="top">(默認: false) 僅在服務器數據改變時獲取新數據。使用 HTTP 包 Last-Modified 頭信息判斷。</td> </tr> <tr> <td width="90" valign="top"><strong>processData </strong></td> <td width="83" valign="top">Boolean</td> <td width="419" valign="top">(默認: true) 默認情況下,發送的數據將被轉換為對象(技術上講并非字符串) 以配合默認內容類型 "application/x-www-form-urlencoded"。如果要發送 DOM 樹信息或其它不希望轉換的信息,請設置為 false。</td> </tr> <tr> <td width="90" valign="top"><strong>success </strong></td> <td width="83" valign="top">Function</td> <td width="419" valign="top">請求成功后回調函數。這個方法有兩個參數:服務器返回數據,返回狀態<br /> <pre><span style="color: rgb(0, 0, 255);">function</span> (data, textStatus) {<br /> <span style="color: rgb(0, 128, 0);">// data could be xmlDoc, jsonObj, html, text, etc...</span> <span style="color: rgb(0, 0, 255);">this</span>; <span style="color: rgb(0, 128, 0);">// the options for this ajax request</span> }</pre> </td> </tr> </tbody> </table> <p> </p> <p>這里有幾個Ajax事件參數:<strong>beforeSend </strong>,<strong>success </strong>,<strong>complete ,error 。</strong>我們可以定義這些事件來很好的處理我們的每一次的Ajax請求。注意一下,這些Ajax事件里面的 <font color="#0000ff">this</font> 都是指向Ajax請求的選項信息的(請參考說 get() 方法時的this的圖片)。<br /> 請認真閱讀上面的參數列表,如果你要用jQuery來進行Ajax開發,那么這些參數你都必需熟知的。</p> <h4>示例代碼,獲取博客園首頁的文章題目:</h4> <pre> $.ajax({<br /> type: "<span style="color: rgb(139, 0, 0);">get</span>",<br /> url: "<span style="color: rgb(139, 0, 0);">http://www.cnblogs.com/rss</span>",<br /> beforeSend: <span style="color: rgb(0, 0, 255);">function</span>(XMLHttpRequest){<br /> <span style="color: rgb(0, 128, 0);">//ShowLoading();</span> }, success: <span style="color: rgb(0, 0, 255);">function</span>(data, textStatus){<br /> $("<span style="color: rgb(139, 0, 0);">.ajax.ajaxResult</span>").html("");<br /> $("<span style="color: rgb(139, 0, 0);">item</span>",data).each(<span style="color: rgb(0, 0, 255);">function</span>(i, domEle){<br /> $("<span style="color: rgb(139, 0, 0);">.ajax.ajaxResult</span>").append("<span style="color: rgb(139, 0, 0);"><li></span>"+$(domEle).children("<span style="color: rgb(139, 0, 0);">title</span>").text()+"<span style="color: rgb(139, 0, 0);"></li></span>");<br /> });<br /> },<br /> complete: <span style="color: rgb(0, 0, 255);">function</span>(XMLHttpRequest, textStatus){<br /> <span style="color: rgb(0, 128, 0);">//HideLoading();</span> }, error: <span style="color: rgb(0, 0, 255);">function</span>(){<br /> <span style="color: rgb(0, 128, 0);">//請求出錯處理</span> } });</pre> <p><input id="btnajax" type="button" value="讀取首頁RSS" /></p> <p class="ajax ajaxResult">這里將顯示首頁文章列表。</p> <p class="ajax ajaxResult"> </p> <p> </p> <p><font color="#bb0000" size="4"><strong>其他</strong></font></p> <p><font color="#bb0000"><strong>jQuery.ajaxSetup</strong>( options ) : 設置全局 AJAX 默認選項。</font></p> <p>設置 AJAX 請求默認地址為 "/xmlhttp/",禁止觸發全局 AJAX 事件,用 POST 代替默認 GET 方法。其后的 AJAX 請求不再設置任何選項參數。</p> <p><strong>jQuery 代碼:</strong></p> <pre> $.ajaxSetup({<br /> url: "<span style="color: rgb(139, 0, 0);">/xmlhttp/</span>",<br /> global: <span style="color: rgb(0, 0, 255);">false</span>,<br /> type: "<span style="color: rgb(139, 0, 0);">POST</span>"<br /> });<br /> $.ajax({ data: myData });</pre> <p> </p> <p><strong><font color="#bb0000" size="4">serialize() 與 serializeArray()</font></strong></p> <p>serialize() : 序列表表格內容為字符串。</p> <p>serializeArray() : 序列化表格元素 (類似 '.serialize()' 方法) 返回 JSON 數據結構數據。</p> <p>示例:</p> <p>HTML代碼:</p> <pre><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">p</span> <span style="color: rgb(255, 0, 0);">id</span>=<span style="color: rgb(0, 0, 255);">"results"</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">b</span><span style="color: rgb(0, 0, 255);">></span>Results: <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">b</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">p</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">form</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">select</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"single"</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span>Single<span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span>Single2<span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">select</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">select</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"multiple"</span> <span style="color: rgb(255, 0, 0);">multiple</span>=<span style="color: rgb(0, 0, 255);">"multiple"</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">option</span> <span style="color: rgb(255, 0, 0);">selected</span>=<span style="color: rgb(0, 0, 255);">"selected"</span><span style="color: rgb(0, 0, 255);">></span>Multiple<span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span>Multiple2<span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">option</span> <span style="color: rgb(255, 0, 0);">selected</span>=<span style="color: rgb(0, 0, 255);">"selected"</span><span style="color: rgb(0, 0, 255);">></span>Multiple3<span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">option</span><span style="color: rgb(0, 0, 255);">></span> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">select</span><span style="color: rgb(0, 0, 255);">></span><span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">br</span><span style="color: rgb(0, 0, 255);">/></span> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">input</span> <span style="color: rgb(255, 0, 0);">type</span>=<span style="color: rgb(0, 0, 255);">"checkbox"</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"check"</span> <span style="color: rgb(255, 0, 0);">value</span>=<span style="color: rgb(0, 0, 255);">"check1"</span><span style="color: rgb(0, 0, 255);">/></span> check1<br /> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">input</span> <span style="color: rgb(255, 0, 0);">type</span>=<span style="color: rgb(0, 0, 255);">"checkbox"</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"check"</span> <span style="color: rgb(255, 0, 0);">value</span>=<span style="color: rgb(0, 0, 255);">"check2"</span> <br /> <br /> <span style="color: rgb(255, 0, 0);">checked</span>=<span style="color: rgb(0, 0, 255);">"checked"</span><span style="color: rgb(0, 0, 255);">/></span> check2<br /> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">input</span> <span style="color: rgb(255, 0, 0);">type</span>=<span style="color: rgb(0, 0, 255);">"radio"</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"radio"</span> <span style="color: rgb(255, 0, 0);">value</span>=<span style="color: rgb(0, 0, 255);">"radio1"</span> <br /> <br /> <span style="color: rgb(255, 0, 0);">checked</span>=<span style="color: rgb(0, 0, 255);">"checked"</span><span style="color: rgb(0, 0, 255);">/></span> radio1<br /> <span style="color: rgb(0, 0, 255);"><</span><span style="color: rgb(128, 0, 0);">input</span> <span style="color: rgb(255, 0, 0);">type</span>=<span style="color: rgb(0, 0, 255);">"radio"</span> <span style="color: rgb(255, 0, 0);">name</span>=<span style="color: rgb(0, 0, 255);">"radio"</span> <span style="color: rgb(255, 0, 0);">value</span>=<span style="color: rgb(0, 0, 255);">"radio2"</span><span style="color: rgb(0, 0, 255);">/></span> radio2<br /> <br /> <span style="color: rgb(0, 0, 255);"></</span><span style="color: rgb(128, 0, 0);">form</span><span style="color: rgb(0, 0, 255);">></span></pre> </li> <li> <p><a target="_blank"><img width="812" height="106" alt="" src="http://images.cnblogs.com/cnblogs_com/yeer/image_thumb_3.png" border="0" /></a></p> <p><strong><font color="#bb0000">serializeArray() 結果為:</font></strong></p> <p><a target="_blank"><img width="513" height="338" alt="image" src="http://images.cnblogs.com/cnblogs_com/yeer/image_thumb_4.png" border="0" style="border-width: 0px;" /></a></p> </li> </ul> <p> </p>
地址:溫州市甌海區站南商貿城C幢306室
總機:0577-55882408;傳真:0577-55882411
E-mail:115047027@qq.com
業務咨詢:0577-55882401
售后熱線:0577-55882408
技術咨詢:0577-55882411
copyright ?
溫州龍誠互聯 版權所有
浙ICP備11044124號-1
您是第
位訪客
主站蜘蛛池模板:
天天爽夜夜爽人人爽免费
|
日本精品久久久免费高清
|
一级片aaa
|
国产精品九九免费视频
|
a毛片成人免费全部播放
|
freexxxx性大陆另类
|
99re热视频这里只有精品5
|
国产亚洲一区二区三区
|
久久综合狠狠综合久久97色
|
国产精品日韩欧美在线第3页
|
亚洲人成77777在线观看网
|
91久久天天躁狠狠躁夜夜
|
91短视频在线免费观看
|
国产一区二区视频在线观看
|
欧美激情二区
|
国产成人综合在线观看
|
国产日本欧美在线观看乱码
|
国产精品免费入口视频
|
色欧美亚洲
|
99热99re8国产在线播放
|
国产丫丫视频私人影院
|
日本一区深夜影院深a
|
欧美成视频人免费淫片
|
欧美在线观看一区二区三
|
又猛又黄又爽无遮挡的视频网站
|
黄色小视频在线观看
|
国产日韩一区在线精品欧美玲
|
午夜影皖
|
午夜在线免费视频
|
色噜噜狠狠狠狠色综合久不
|
成人毛片100部免费看
|
精品成人在线观看
|
在线精品视频成人网
|
国产美女丝袜黑色视频
|
外国成人网在线观看免费视频
|
国产高清日韩
|
欧美家庭影院
|
国产精品自在线天天看片
|
www.最色
|
日韩一二三
|
野花影视视频在线观看免费
|
0
在线咨询
业务咨询
技术咨询
服务咨询
请您留言
温州龙诚互联科技有限公司 0577-55882408
提交
感谢留言
我们会尽快与您联系
关闭