All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
解决Ajax中文乱码问题_[AJAX教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/3/16 2:55:44 Browse times: 303 Comment times: 0

解决Ajax中文乱码问题_[AJAX教程]


Head photo

Go homepage
Upload pictures
Write articles

解决Ajax中文乱码问题_[AJAX教程]























网上有很多解决这个问题的方法,试了一下都不好用,自己就对于这些方法测试了一下,然后逐个排除无用的设置,最后得到了最简单的方案。





js代码:
得到XmlHttpRequest的类
Code
1function HttpRequest()
2{
3 //取得Request对象
4 this.Request=function(){
5 try
6 {
7 if(window.XMLHttpRequest) request=new XMLHttpRequest();
8 if(!request)request=new ActiveXObject("Microsoft.XMLHTTP");
9 if(!request)request=new ActiveXObject("Msxml2.XMLHTTP");
10 return request;
11 }
12 catch(e)
13 {
14 alert("不支持XMLHTTPRequest");
15 }}
16}调用过程:
Code
1<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AjaxTest._Default" %>
2
3
4
5
6 Untitled Page
7
8
9
10
34
35
36
37
38


39
40


41
42
43
44后台取得输入值:
protected void Page_Load(object sender, EventArgs e)
{
string value = Request["Value"];
}
测试过,可以得到正确的输入字符。

来源:http://www.cnblogs.com/jingtao











































There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.