Home > Web Front-end > JS Tutorial > A process of solving Jquery garbled code Illustrated tutorial_jquery

A process of solving Jquery garbled code Illustrated tutorial_jquery

WBOY
Release: 2016-05-16 18:34:05
Original
880 people have browsed it

Untitled-1

Untitled-2 

简单的请求,简单的响应,但是乱码产生了

Untitled-3

Why?

乱码之所以产生,原因很简单,无非就是编码表用错了,如传的是big5字符,接收却使用utf-8,或utf-8编码,却用GB2312解码。

 

好吧,先确认一下是否请求过程中产生的乱码

Untitled-4

 

那我发过去的是乱码吗?

Untitled-5

 

打开C:/tmp/下的test.txt

Untitled-6

 

这是什么编码,猜一猜?

Untitled-7

 

看来客户端没错,且正确地到了服务器端了,那应该是asp.net搞错了编码了,HttpRequest类里找下有没有相关的Encoding相关的属性

Untitled-8

Untitled-9 

 

看看web.config吧

Untitled-10

测试一下修改成utf-8看看

Untitled-11

原因成功找到,看来就是客户端传utf-8,然后服务器端big5接收产生问题

不过这个专案不能这样解决,因为这个旧专案跑了很久了,改这里可能影响以前的其它程式,那就改客户端吧,设置请求属性为utf-8,让asp.net不迷茫

修改ajax请求代码,设定charset属性

Untitled-12

 

问题得以解决,不过最近也有在vs2005中使用jquery,没有发生乱码,可能是vs2005已经默认为utf-8了(有空再去找下是在哪里默认的,或那位TX告知一下)

 

vs.net2003默认是本机操作系统的编码,如big5,gb2312,因此常常发生乱码问题.

 

Also, share a simple method to view garbled text files.

Untitled-14

Untitled-15

For some text files that do not end with txt (such as aspx, cs), you can change the suffix to txt first, and then open IE to view it, otherwise IE will not recognize it, so download it directly

There are too many pictures, please forgive me if the TX speed is slow~~

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template