if(document.getElementById(callerName).checked) {
//alert(callerName);
var poststr = "field=" + escape(encodeURI(callerName)) +
"&op=add" + "&nocache=" + nocache;
}
else {
//alert(callerName);
var poststr = "field=" + escape(encodeURI(callerName)) +
"&op=del" + "&nocache=" + nocache;
}
http.send(poststr);
当我收到$_POST['field']
我得到的'%20'有空格时,有什么解决方案可以获得确切的字符串吗?
答案 0 :(得分:1)
PHP:
$field = urldecode($_POST['field']);
答案 1 :(得分:0)
您同时使用escape
和encodeURI
双重转发数据。另外,我建议您改用encodeURIComponent
。尝试改为:
var poststr = "field=" + encodeURIComponent(callerName) +
"&op=add&nocache=" + nocache;