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
