我通過AJAX to a PHP script
提交表單字段的內容,並使用此代碼AJAX POST和Plus(+)和(&)Sign如何編碼?
if(!http)
http = CreateObject();
nocache = Math.random();
http.open('post', 'addvm.php');
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
http.onreadystatechange = SaveReply;
http.send(params);
的問題是,任何+ and &
跡象被剝離並更換。我如何安全地'編碼'+ and &
標誌,然後在PHP端正確地「解碼」它?
@metaforce:bro可以添加它,它是如何使用的? – Harsh 2011-05-18 11:05:44
只是將您的代碼的最後一行更改爲: http.send(encodeURIComponent(params)); //然後用urldecode在你的服務器上捕捉它,如果你願意的話...... – metaforce 2011-05-18 11:10:25
在評論中有錯誤的表達:)只是發送方法的參數值.. – metaforce 2011-05-18 11:16:55