Javascript 如何从Resource文件修复西班牙语严重口音问题?
多语言功能在资源文件中的普通html页面中工作正常,但在javascript方面失败,例如: 成功在于html页面中西班牙语的“éxito”,它工作正常,但在javascript中显示为É;希托Javascript 如何从Resource文件修复西班牙语严重口音问题?,javascript,jquery,asp.net-mvc,resx,Javascript,Jquery,Asp.net Mvc,Resx,多语言功能在资源文件中的普通html页面中工作正常,但在javascript方面失败,例如: 成功在于html页面中西班牙语的“éxito”,它工作正常,但在javascript中显示为É;希托 如果我们在javascript中将“éxito”硬编码为字符串,它也可以工作,但从Resource文件加载到javascript时失败 function Login_Create_user(id) { $.ajax({ url: '@Url.Actio
如果我们在javascript中将“éxito”硬编码为字符串,它也可以工作,但从Resource文件加载到javascript时失败
function Login_Create_user(id) {
$.ajax({
url: '@Url.Action("CreateLogin", "User")',
type: "POST",
async: false,
data: { studentId: Id },
success: function(result1) {
if (result1 == true) {
swal("@Resource.Success", "StudentLoginCreatedSuccessfully.", "success");
window.location.reload();
} else if (result1 == false) {
swal("@Resource.warning", "@Resource.FailedtoCreatelogin ! @Resource.Pleasetryagainlater", "warning");
} else {
swal("@Resource.warning", result1, "warning");
}
},
error: function(ex) {
}
});
}
我希望从Resource文件加载到javascript时,“éxito”应该作为“éxito”加载您可以使用纯
javascript
或Jquery
使用以下任何函数解码ajax响应
//Decode HTML-entities (JS)
function decodeHTMLEntities(text) {
var textArea = document.createElement('textarea');
textArea.innerHTML = text;
return textArea.value;
}
//Decode HTML-entities (JQuery)
function decodeHTMLEntities(text) {
return $("<textarea/>")
.html(text)
.text();
}
decodeHTMLEntities('Éxito')
//解码HTML实体(JS)
函数属性(文本){
var textArea=document.createElement('textArea');
textArea.innerHTML=文本;
返回textArea.value;
}
//解码HTML实体(JQuery)
函数属性(文本){
返回$(“”)
.html(文本)
.text();
}
解码特性('É;xito')
产出:“埃希托”
使用解码组件。