ie下$.getJSON出現問題的解決方案

來源:互聯網
上載者:User

ie下$.getJSON出現問題的解決方案

 ie下$.getJSON出現問題是常有的事,下面為大家介紹下具體該如何解決,需要的朋友可以參考下

前提:需匯入相關js檔案jquery.js 

 

$.post(url,data,success(data, textStatus, jqXHR),dataType) 

 

url:必需。規定把請求發送到哪個 URL。 

 

data:可選。映射或字串值。規定連同請求發送到伺服器的資料。 

 

success(data, textStatus, jqXHR):可選。請求成功時執行的回呼函數。 

 

dataType:預設執行智能判斷(xml、json、script 或 html)。 

 

$.getJSON(url,data,success(data, textStatus, xhr)) 

 

url:必需。規定將請求發送的哪個 URL。 

 

data:可選。規定連同請求發送到伺服器的資料。 

 

success(data,status,xhr): 

 

可選。規定當請求成功時啟動並執行函數。 

 

額外的參數: 

 

response - 包含來自請求的結果資料 

status - 包含請求的狀態 

xhr - 包含 XMLHttpRequest 對象 

 

擴充寫為: 

 代碼如下:

$.ajax({ 

 

type:'POST'或'GET', 

 

url:url, 

 

data:data, 

 

success:callback, 

 

dataType:json 

 

}); 

 

dataType有這幾種類型:xml、json、script 或 html 

 

注意: 

 

採用$.getJson方法時,如果有中文字元傳入url中需先轉義(不轉義的話ie8下$_GET['v']將會得不到值,其他瀏覽器無此問題) 

 

eg: 

 

var url = "/api.php?op=product&v="+encodeURIComponent('好好學習'); 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.