我应该如何对使用 XMLHttpRequest 发送的表单值进行编码

问题描述

我想知道在将表单值发送到带有 XMLHttpRequest 的 .asp 页面时对表单值进行编码的正确方法是什么,然后在将其插入到我的数据库之前在 .asp 页面上对其进行解码。所以我可以使用这样的字符 #%?´:;!+-'

我是否使用encodeURIComponent(the string value here)

所以假设表单在 page1.asp 中

<form action="#"  id="saveuploads" ENCTYPE="multipart/form-data" class="form-ajax-submit">
<input type="text" name="artikel" >
</form>

// lets say I have a string in the form with the value `#%?´:;!+-'`

artikel=encodeURIComponent('#%?´:;!+-'')
fdu.append("artikel",artikel);

var xhr = new XMLHttpRequest();
xhr.open("POST","upload2.asp");
xhr.send(fdu);

然后在page2.asp 我应该用

解码吗

artikel=decodeURIComponent(request.form("artikel"))

然后将artikel插入数据库...

感谢任何输入,谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)