2011-08-27 40 views
1

HTTPRequestObject的位置字符串在哪裏通過「POST」發送到php文件?我試過尋找$ _POST和$ _REQUEST數組。通過POST發送到php文件的信息的位置通過HTTPRequestObject.send函數

我使用發送類似如下:

request.send( 「NAME =」 +名字+ 「&評論=」 +評論);

從javascript發送數據到一個php文件,在那裏我鬆了它。請求通過(我檢查onreadystatechange),並且我在公開呼叫中使用POST方法。

回答

0

試試這個:

request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 

request.send()

此時應更換:

request.send("name="+name+"&comment="+comment); 

有:

request.send("name="+encodeURIComponent(name)+"&comment="+encodeURIComponent(comment)); 
+0

優秀,謝謝。 (顯然是AJAX新手) – nschomer

+0

很高興我能幫忙:) – stewe

0

「窗體-urlencoded」 並不是指一個屁股ociative數組。我認爲「request.send(」name =「+ name +」& comment =「+ comment);」是正確的。