亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

使用AJAX實現(xiàn)UTF8編碼表單提交到GBK編碼腳本無亂碼的解決方法

瀏覽:120日期:2022-06-04 16:28:08

1、表單項目1 GBK編碼格式

用戶采集單是GBK編碼,通過GET/POST提交上來的數(shù)據(jù)也是GBK格式,無需做任何處理

測試源碼

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="GB2312">
</head>
<body>
<li><a href="gbkForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GBK同編碼表單不亂碼</a>
<li><a href="utf8Form.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改前亂碼</a>
<li><a href="utf8FormRepair.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改為AJAX方案后不亂碼</a>
<li><a href="otherForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他GBK同編碼表單不亂碼</a>
<li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >測試程序說明</a></a>
<hr />
<h2>GET:</h2>
<form action="gbkSubmit.asp" method="GET" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<button type="submit">GBK表單提交到GBK腳本后不會亂碼</button>
</form>
<h2>POST:</h2>
<form action="gbkSubmit.asp" method="POST" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<button type="submit">GBK表單提交到GBK腳本后不會亂碼</button>
</form>
</body>
</html>

2、表單項目2 UTF8編碼格式(可以在不同的域名下)

用戶采集單是UTF8編碼,通過GET/POST提交上來的數(shù)據(jù)也是UTF8格式,用表單項目1中的程序接收到的是亂碼

測試代碼(修改前,提交亂碼):

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF8">
</head>
<body>
<li><a href="gbkForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GBK同編碼表單不亂碼</a>
<li><a href="utf8Form.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改前亂碼</a>
<li><a href="utf8FormRepair.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改為AJAX方案后不亂碼</a>
<li><a href="otherForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他GBK同編碼表單不亂碼</a>
<li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >測試程序說明</a></a>
<hr />
<h2>GET:</h2>
<form action="gbkSubmit.asp" method="GET" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<button type="submit">UTF8表單提交到GBK腳本后會亂碼</button>
</form>
<h2>POST:</h2>
<form action="gbkSubmit.asp" method="POST" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<button type="submit">UTF8表單提交到GBK腳本后會亂碼</button>
</form>
</body>
</html>

不需要改變頁面編碼,只需要修改表單Action地址,增加name=”ConvertCallBack” value=”ProjectA/FormGBK”、name=”ConvertItems” value=”name,qq,bb” 的兩個 input即可,不用對頁面進行其他調整
編碼設置,轉換器自動操作。

<form action="convert/utf8.asp"...
<input name="ConvertCallBack" value="ProjectA/FormGBK">
<input name="ConvertItems" value="name,qq,address"/>
<!-- 根據(jù)表單實際情況,修改表單項目 -->

測試代碼(修改后)

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF8">
</head>
<body>
<li><a href="gbkForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GBK同編碼表單不亂碼</a>
<li><a href="utf8Form.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改前亂碼</a>
<li><a href="utf8FormRepair.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改為AJAX方案后不亂碼</a>
<li><a href="otherForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他GBK同編碼表單不亂碼</a>
<li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >測試程序說明</a></a>
<hr />
<h2>GET:</h2>
<form action="convert/utf8.asp" method="GET" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<input name="ConvertCallBack" value="../gbkSubmit.asp" />
<input name="ConvertItems" value="name,qq,address" />
<button type="submit">AJAX轉碼方案</button>
</form>
<h2>POST:</h2>
<form action="convert/utf8.asp" method="POST" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
<input name="ConvertCallBack" value="../gbkSubmit.asp" />
<input name="ConvertItems" value="name,qq,address" />
<button type="submit">AJAX轉碼方案</button>
</form>
</body>
</html>

3、表單項目3 GBK編碼格式(可以在不同的域名下)

沒有任何影響,只要按照表單1的標準編寫 參數(shù)即可
測試代碼:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="GB2312">
</head>
<body>
<li><a href="gbkForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >GBK同編碼表單不亂碼</a>
<li><a href="utf8Form.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改前亂碼</a>
<li><a href="utf8FormRepair.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >UTF8表單修改為AJAX方案后不亂碼</a>
<li><a href="otherForm.html" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其他GBK同編碼表單不亂碼</a>
<li><a  rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >測試程序說明</a></a>
<hr />
<h2>GET:</h2>
<form action="gbkSubmit.asp" method="GET" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
Other1:<input name="other1" value="Other1"/><br />
Other2:<input name="other2" value="Other2"/><br />
Other3:<input name="other3" value="Other3"/><br />
Other4:<input name="other4" value="Other4"/><br />
Other5:<input name="other5" value="Other5"/><br />
Other6:<input name="other6" value="Other6"/><br />
Other7:<input name="other7" value="Other7"/><br />
Other8:<input name="other8" value="Other8"/><br />
Other9:<input name="other9" value="Other9"/><br />
<button type="submit">GBK表單提交到GBK腳本后不會亂碼</button>
</form>
<h2>POST:</h2>
<form action="gbkSubmit.asp" method="POST" >
QQ:<input name="qq" value="QQ" /><br />
姓名:<input name="name" value="姓名"/><br />
地址:<input name="address" value="地址地址地址"/><br />
Other1:<input name="other1" value="Other1"/><br />
Other2:<input name="other2" value="Other2"/><br />
Other3:<input name="other3" value="Other3"/><br />
Other4:<input name="other4" value="Other4"/><br />
Other5:<input name="other5" value="Other5"/><br />
Other6:<input name="other6" value="Other6"/><br />
Other7:<input name="other7" value="Other7"/><br />
Other8:<input name="other8" value="Other8"/><br />
Other9:<input name="other9" value="Other9"/><br />
<button type="submit">GBK表單提交到GBK腳本后不會亂碼</button>
</form>
</body>
</html>

全部測試包下載地址 anycharset_jb51.rar

utf8.asp

<% @codepage=936 %>
<%
  CallBack = Server.Htmlencode(Request("ConvertCallBack"))
  Items = Split(Request("ConvertItems"),",")
  if len(request.form) > 0 then
    method = "POST"
  else
    method = "GET"
  end if
%><!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="GB2312">
<script src="http://www.miaoqiyuan.cn/wp-includes/js/jquery/jquery.js"></script>
</head>
<body>
<form action="<%=CallBack%>" method="<%=method%>" id="AutoPOST">
<%
  for each Item in Items
    if trim(Item) <> "" then
      Item = Server.Htmlencode(Item)
%><% = Item %> : <textarea name="<% = Item %>" id="<% = Item %>"></textarea><br />
<script>
jQuery.post("utf8_convert.asp?MiaoQiYuanAutoConvertItem=<%=Item%>&<%=Request.QueryString%>","<%=Request.Form%>",function(res){
  jQuery("#<% = Item %>").val(res);
});
</script>
<%
    end if
  next
%>
<button type="submit">Waiting...</button>
<script type="text/javascript">
setTimeout(function(){
  jQuery("#AutoPOST").submit();
},200);
</script>
</body>
</html>

utf8_convert.asp

<% @codepage=65001 %>
<%
  function NotXSS(html)
    NotXSS = html
    NotXSS = replace(NotXSS, "<", "&lt;")
    NotXSS = replace(NotXSS, ">", "&gt;")
    NotXSS = replace(NotXSS, """", "&quote;")
  end function
   
  "防止參數(shù)沖突,使用了 MiaoQiYuanAutoConvertItem
  Response.Write NotXSS(Request(Request.QueryString("MiaoQiYuanAutoConvertItem")))
%>

到此這篇關于使用AJAX實現(xiàn)UTF8編碼表單提交到GBK編碼腳本無亂碼的解決方法的文章就介紹到這了,更多相關UTF8編碼表單提交到GBK編碼內容請搜索以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持!

標簽: ASP
相關文章:
主站蜘蛛池模板: 婷婷丁香五月中文字幕 | 国产免费一区二区三区在线 | 成人免费网址在线 | 国产一区二区三区在线视频 | 亚洲综合电影 | 免费在线观看a级片 | 欧美精品一区视频 | 嫩草影院永久在线播放 | 国产成人亚洲综合无 | 看a级毛片 | 欧美系列在线播放 | 国产一区二区不卡视频 | 激情在线免费视频 | 91久久久久久久 | 一级毛片免费视频日本 | 99久久综合狠狠综合久久aⅴ | 国产在线观看一区二区三区四区 | 亚洲性夜夜时 | a级毛片免费观看在线播放 a级毛片免费观看网站 | 国产综合成色在线视频 | 国产乱人视频免费观看 | 国产51页 | 欧美大片在线观看成人 | 老外一级毛片免费看 | 国内自拍视频在线观看 | 黄色免费小网站 | 久久丝袜视频 | 日韩免费一级毛片 | 乱人伦99久久 | 亚洲欧洲精品视频在线观看 | 97视频在线播放 | 国产农村1级毛片 | 久草一级片 | 国产亚洲一区二区三区在线观看 | 婷婷色天使在线视频观看 | 特级aa一级欧美毛片 | 色综合亚洲综合网站综合色 | 青青草国产三级精品三级 | 国产精品久久久久久免费 | 亚洲精品视频免费看 | 久久精品综合视频 |