发布请求被切断 [英] Post request gets cut off
本文介绍了发布请求被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在javascript中的发帖请求有问题.
I have a problem with my post request in javascript.
我有以下代码用于发送发帖请求
I have the following code for sending the post request
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应用程序中,我这样收到它
And in my node.js express application i receive it like this
var username = req.body.username;
现在,这可以正常使用正常字符(数字和字母).但是当我尝试
Now this works perfect with normal characters (numbers and letters). But when i tried
>df)(*&&^%$
作为用户名被切断为
>df)(*
我怀疑是因为&.
I suspect it is because of the &.
我的问题:如何防止其被切断.
My question: How do i prevent it from getting cut off.
提前谢谢!
推荐答案
您需要使用 xhttp.send("username =" +encodeURIComponent(用户名));
这篇关于发布请求被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文