ajax獲取數(shù)據(jù)中文亂碼問題最簡單的完美解決方案
更新時間:2014年11月24日 15:31:58 投稿:hebedich
這篇文章主要介紹了ajax獲取數(shù)據(jù)中文亂碼問題最簡單的完美解決方案,需要的朋友可以參考下
使用scriptCharset即可解決問題,用contentType就不一定可以了。
復(fù)制代碼 代碼如下:
$.ajax({
url: testUrl,
dataType: 'jsonp',
type: 'post',
scriptCharset: 'utf-8'
});
上面的解決方案是最完美的,另外也附上網(wǎng)上的解決方式吧,是用contentType來處理的
復(fù)制代碼 代碼如下:
jQuery(form).ajaxSubmit({
url: "ajax.aspx?a=memberlogin",
type: "post",
dataType: "json",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
success: showLoginResponse
});
雖然也可以用,但是不推薦給大家哈。
相關(guān)文章
Ajax返回數(shù)據(jù)之前的loading等待效果
我們通過ajax請求,向后臺傳遞參數(shù),然后后臺經(jīng)過一系列的運算之后向前臺返還數(shù)據(jù),我希望在等待數(shù)據(jù)成功返還之前可以展示一個loading.gif圖。接下來通過本文給大家分享Ajax返回數(shù)據(jù)之前的loading等待效果,需要的朋友可以參考下2017-08-08