利用AJAX实现UTF8编码表单提交到GBK编码剧本无乱码(2)

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="GB2312"> </head> <body> <li><a href="https://www.jb51.net/gbkForm.html" >GBK同编码表单不乱码</a> <li><a href="https://www.jb51.net/utf8Form.html" >UTF8表单修改前乱码</a> <li><a href="https://www.jb51.net/utf8FormRepair.html" >UTF8表单修改为AJAX方案后不乱码</a> <li><a href="https://www.jb51.net/otherForm.html" >其他GBK同编码表单不乱码</a> <li><a href="https://www.miaoqiyuan.cn/p/utf8-submit-gbk-ajax-autocharset" >测试措施说明</a></a> <hr /> <h2>GET:</h2> <form action="gbkSubmit.asp" method="GET" > QQ:<input value="QQ" /><br /> 姓名:<input value="姓名"/><br /> 地点:<input value="地点地点地点"/><br /> Other1:<input value="Other1"/><br /> Other2:<input value="Other2"/><br /> Other3:<input value="Other3"/><br /> Other4:<input value="Other4"/><br /> Other5:<input value="Other5"/><br /> Other6:<input value="Other6"/><br /> Other7:<input value="Other7"/><br /> Other8:<input value="Other8"/><br /> Other9:<input value="Other9"/><br /> <button type="submit">GBK表单提交到GBK剧本后不会乱码</button> </form> <h2>POST:</h2> <form action="gbkSubmit.asp" method="POST" > QQ:<input value="QQ" /><br /> 姓名:<input value="姓名"/><br /> 地点:<input value="地点地点地点"/><br /> Other1:<input value="Other1"/><br /> Other2:<input value="Other2"/><br /> Other3:<input value="Other3"/><br /> Other4:<input value="Other4"/><br /> Other5:<input value="Other5"/><br /> Other6:<input value="Other6"/><br /> Other7:<input value="Other7"/><br /> Other8:<input value="Other8"/><br /> Other9:<input 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="https://www.miaoqiyuan.cn/wp-includes/js/jquery/jquery.js"></script> </head> <body> <form action="<%=CallBack%>" method="<%=method%>"> <% for each Item in Items if trim(Item) <> "" then Item = Server.Htmlencode(Item) %><% = Item %> : <textarea></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 '防备参数斗嘴,利用了 MiaoQiYuanAutoConvertItem Response.Write NotXSS(Request(Request.QueryString("MiaoQiYuanAutoConvertItem"))) %>

到此这篇关于利用AJAX实现UTF8编码表单提交到GBK编码剧本无乱码的办理要领的文章就先容到这了,更多相关UTF8编码表单提交到GBK编码内容请搜索剧本之家以前的文章或继承欣赏下面的相关文章但愿各人今后多多支持剧本之家!

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsdffj.html