1. 程式人生 > >IE瀏覽器 ajax傳參數值為中文時出現亂碼的解決方案

IE瀏覽器 ajax傳參數值為中文時出現亂碼的解決方案

on() ajax code pan cti .ajax ole style func

找了很多方法,發現就這個方法簡單、直接、方便,直接推薦哦!

在漢字的位置加個保護措施:encodeURIComponent(parentid)

舉個栗子>>>

$.ajax({
url: ‘url‘+ encodeURIComponent("中文參數值"),
type: ‘GET‘,
dataType: ‘JSON‘,
timeout: 5000,
error: function() { alert(‘error msg‘); },
success: function(resp) {
  console.log(resp);

}
});

IE瀏覽器 ajax傳參數值為中文時出現亂碼的解決方案