【发布时间】:2010-07-04 15:08:30
【问题描述】:
我正在尝试在 jquery 调用中设置 charSet 我正在为立陶宛朋友制作的网站因此有一些带有重音符号等的字母。
就我目前的研究(值得 2 天!!!)显示,我需要将它放在我所做的 beforeSend 部分中:
$(document).ready(function(){
$('.content').load('home.html'); //by default initally load text from boo.php
$('#navlist a').click(function() { //start function when any link is clicked
$(".content").slideUp("slow");
var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php file
$.ajax({
method: "load",url: ""+content_show,
beforeSend: function(){
XMLHttpRequest.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
$("#loading").show("fast");
}, //show loading just when link is clicked
complete: function(){ $("#loading").hide("fast");}, //stop showing loading when the process is complete
success: function(html){ //so, if data is retrieved, store it in html
$(".content").show("slow"); //animation
$(".content").html(html); //show the html inside .content div
}
}); //close $.ajax(
}); //close click(
}); //close $(
我试过改成
setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
这也行不通,所以现在我被困住了,四处看了两天,我的神经快到了尽头。
可以在 43dennis.co.nr/bivakas 上查看该网站。基本上,它加载了一堆黑色方形问号,而不是带有特殊口音的字母。
非常感谢您的帮助。
【问题讨论】:
-
哦.. 使用 XMLHttpRequest.setRequestHeader 或仅使用 setRequestHeader 函数甚至都不起作用......抱歉忘了提及
标签: javascript jquery ajax