Sul*_*lan 0 javascript jquery character-encoding
我正在使用jquery AJAX加载将一个html页面加载到div.加载的页面具有德语字符,并且编码不正确,而主页面中的德语字符显示正确.有人请帮我解决这个问题.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-15"/>
<script type="text/javascript" src="script/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
url : 'startPage.html',
dataType: 'text',
contentType: "application/x-www-form-urlencoded;charset=utf-8",
success : function(data){
$('#loadPage').html(data);
}
});
});
</script>
</head>
<body>
<div id="loadPage"></div>
<br />
Länge Länge
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-15"/>
</head>
<body>
Loaded Content - Länge - (This text is not displayed correctly)
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在此页面中,我尝试为iso编码添加元标记,但仍未取得任何成功.请帮忙
beforeSend : function(xhr) {
xhr.overrideMimeType('text/html; charset=iso-8859-15');
},
Run Code Online (Sandbox Code Playgroud)
在你的ajax函数或ajaxSetup()中使用它;