【发布时间】:2017-08-14 12:54:38
【问题描述】:
我的 javascript 发布请求有问题。
我有以下代码用于发送发布请求
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{
if (this.readyState == 4 && this.status == 200)
{
//stuff
}
};
xhttp.open("POST", "/deleteUser", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("username=" + username);
在我的 node.js express 应用程序中,我像这样收到它
var username = req.body.username;
现在这对普通字符(数字和字母)非常有效。但是当我尝试
>df)(*&&^%$
作为用户名,它被切断
>df)(*
我怀疑这是因为 &。
我的问题:我如何防止它被切断。
提前致谢!
【问题讨论】:
标签: javascript ajax node.js