最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

關(guān)于Ajax請(qǐng)求中傳輸中文亂碼問題的解決方案

 更新時(shí)間:2016年12月02日 13:49:45   作者:老姐不老  
本文給大家分享關(guān)于ajax請(qǐng)求中文亂碼問題的解決方案,非常不錯(cuò),具有參考借鑒價(jià)值,感興趣的朋友一起看看吧

今天遇到一個(gè)問題,有關(guān)ajax 請(qǐng)求中傳輸中文,遇到亂碼的問題。

如下代碼:

function UpdateFolderInfoByCustId(folderId, folderName, custId) {
$.ajax({
type: "Post",
contentType: "application/x-www-form-urlencoded; charset=utf-8",
url: "http://localhost/CRM/Ashx/HandKBSucessCustomer.ashx?Method=UpdateCustomerByCustId&folderId=" 
+ folderId + "&folderName=" + encodeURI(encodeURI(folderName)) + "&custId=" + custId,
success: function (msg) {
alert(msg);
},
error: function (error) {
alert(error);
}
});
}

如上代碼 如果只是傳“&foderName=”+folderName 的話,漢字就會(huì)產(chǎn)生亂碼,如果經(jīng)過encodeURL 轉(zhuǎn)換兩次的話,漢字編碼會(huì)變?yōu)轭愃?/p>

“%e6%b5%8b%eb%af%95” 的格式。轉(zhuǎn)換為這種格式之后,在獲取的時(shí)候在轉(zhuǎn)碼,如下所示:

public void UpdateCustomerByCustId()
{
int folderId = Convert.ToInt32(Request["folderId"]);
string folderName = Request["folderName"];
string folderName2 = Convert.ToString(System.Web.HttpUtility.UrlDecode(folderName));
int custId = Convert.ToInt32(Request["custId"]);
bool res = false;
try
{
res = CustomerBusiness.UpdateCustomerByCustId(folderId, folderName2, custId);
}
catch (Exception ex)
{
throw;
}
Response.Write(res);
}
}
}

經(jīng)此轉(zhuǎn)換之后,即可獲取到傳輸?shù)臐h字。

以上所述是小編給大家介紹的關(guān)于Ajax請(qǐng)求中傳輸中文亂碼問題的解決方案,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持

相關(guān)文章

最新評(píng)論

彝良县| 上高县| 平乡县| 遂宁市| 双柏县| 贵南县| 日土县| 开远市| 武鸣县| 许昌县| 濉溪县| 铜鼓县| 温州市| 时尚| 台湾省| 永年县| 武功县| 徐闻县| 贵溪市| 分宜县| 日土县| 奉化市| 博乐市| 光山县| 巴彦县| 扎鲁特旗| 海原县| 樟树市| 高陵县| 临海市| 康平县| 怀集县| 晋城| 巫山县| 海城市| 汉寿县| 河曲县| 泸溪县| 阿合奇县| 潮州市| 丁青县|