ajax獲取數據中文亂碼問題最簡單的完美解決方案

轉載地址:http://www.jb51.net/article/57783.htm

使用scriptCharset即可解決問題,用contentType就不一定可以了。

代碼如下:

$.ajax({ 
      url: testUrl, 
      dataType: 'jsonp', 
      type: 'post', 
      scriptCharset: 'utf-8'
    });

上面的解決方案是最完美的,另外也附上網上的解決方式吧,是用contentType來處理的


代碼如下:

jQuery(form).ajaxSubmit({ 
url: "ajax.aspx?a=memberlogin", 
type: "post", 
dataType: "json", 
contentType: "application/x-www-form-urlencoded; charset=utf-8", 
success: showLoginResponse 
});
雖然也可以用,但是不推薦給大家哈。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章