0

我在我的表单中的 demoUrlName(文本字段 id)中传递了这个 url 值 例如, http: //common360.info/browse.php?u=uushJYHAjQLTHh2twPpHjQMbEl4%3D&b=5&f=norefer

我使用 xmlHttpRequest 将此值重定向到另一个页面。问题是,在通过 xmlHttpRequest 和重定向页面发送表单值时,url 值被截断为 http://common360.info/browse.php?u=uushJYHAjQLTHh2twPpHjQMbEl4=

如何按原样发送值我在表单中输入。

我的代码是

    var str = trim(document.getElementById('demoUrlName').value);
    var str = "action=demo&url="+str+"&urlqstr="+urlqstr+"&pgesrc="+pgesrc+"&r="+ran_number;
    var url = "demo/demoTool.php";
    xmlhttp.open("POST", url, true);  
    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
    xmlhttp.send(str);
4

3 回答 3

2

使用encodeURIComponent函数编码&为数据,而不是将它们用作“键/值对分隔符”

于 2013-04-04T14:27:55.950 回答
2

因为您需要对值进行编码。

编码URI组件

于 2013-04-04T14:28:02.940 回答
0

我使用了 escape() 函数,它以形式发送值

于 2013-04-05T05:19:55.107 回答