簡體   English   中英

使用http.send()Ajax

[英]Using http.send() ajax

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'哪里有空格..任何解決方案來獲取確切的字符串?

PHP:

$field = urldecode($_POST['field']);

您正在使用escapeencodeURI雙重轉義數據。 另外,我建議您改用encodeURIComponent 嘗試更改為此:

var poststr = "field=" + encodeURIComponent(callerName) + 
  "&op=add&nocache=" + nocache;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM