English 中文(简体)
图集在使用Ajax时的编码? J Query
原标题:Chartset encoding when using Ajax ? JQuery

我有一个网络应用程序(UTF-8),其中可使用以下软件向服务器一侧发送。

áéíóú
àèìòù
ÀÈÌÒÙ
ÁÉÍÓÚ

Ok. 我使用以下数据发送数据。

// Notice $("#myForm").serialize()
$.get("/path?", $("#myForm").serialize(), function(response) {

});

当我看到我的纪录Set时,即获得(数据库CcharSet encoding为UTF-8)。

áéíóú
à èìòù
ÃÉÃÓÚ
ÀÈÌÒÙ

即便使用员额,也取得相同结果。

在《行动手册》中看到序列化方法:

创建a 适当格式和编码查询 摘录中的所有成功形式要素

但如上所示,这似乎并不奏效。 因此,不采用序号法,即使用

var objectArray =  $("#myForm").serializeArray();

var queryString = "";
for(var i = 0; i < objectArray.length; i++) {
    queryString += "&" + objectArray[i]["name"] + "=" + objectArray[i]["value"];
}

$.get("/path?" + queryString, null, function(response) {

});

现在i 进入数据库

áéíóú
àèìòù
ÀÈÌÒÙ
ÁÉÍÓÚ

因此,在使用序列号(序列)方法时,“一”缺失的东西? 为什么序列化方法不能像预期的那样发挥作用?

问题回答

我在公共卫生和社会福利部下决心:

foreach($_POST as $key => $value) {
    $_POST[$key] = utf8_decode($value);
}

jQuery.get like all the functions jQuery ajax use encodeURIComponent for the data. If you send data via GET, the XHR automatically takes care of passing the encoding of URLs. You can view the documentation of encode to see which type of encoding is suitable for the data you send

我与IEE有着同样的问题。 我在上页上添加了以下文字:

$.ajaxSetup({
       contentType: "application/x-www-form-urlencoded; charset=UTF-8"
});

这些问题似乎与大部分方面解决。

您应在发起和接收网页的负责人上添加以下元子:

<meta http-equiv="Content-type" content="text/html; charset=utf-8" />

这本页将遗漏图八的内容。 如果仅凭这种工作,除在发送时对特性进行编码外,还可使用<条码>encodeURIComponent(。 如果编码编码自动编码,操作decodeURIComponent(,则需要填写。

宇宙化并不与IEE和ISO-8859-1焦炭合作。

见http://forum.jquery.com/topic/serialize-problem-with-latin-1-iso-8859-1-and-solution”rel=“nofollow”http://forum.jquery.com/topic/serialize-problem-with-latin-1-iso-8859-1-and-solution

我也加上试验

if( $.browser.msie )

由于FF的工作和这一黑板的工作。





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...