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


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

$.ajax({  
                type: "get",  
                async: false,  
                url: requesturl,  
                data:{},
                dataType: "jsonp",  
                jsonp: "callback",  
                jsonpCallback:"JsonCallback",
              scriptCharset: 'utf-8',
                success: function (json) {  
                    console.log(json);  
                },  
                error: function (e) {  
                    console.log(e);  
                }  
            });
 

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

jQuery(form).ajaxSubmit({ 
url: "ajax.aspx?a=memberlogin", 
type: "post", 
dataType: "json", 
contentType: "application/x-www-form-urlencoded; charset=utf-8", 
success: showLoginResponse 
});

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM