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);
When I recieve the $_POST['field']
i get '%20' where there are spaces..any solution to get exact the string?
PHP:
$field = urldecode($_POST['field']);
You are double-escaping your data by using both escape
and encodeURI
. Also, I'd recommend you use encodeURIComponent
instead. Try changing to this:
var poststr = "field=" + encodeURIComponent(callerName) +
"&op=add&nocache=" + nocache;