[問題] ajax post send的parameter

看板Ajax作者 (踢恩)時間17年前 (2008/07/07 09:15), 編輯推噓0(0010)
留言10則, 3人參與, 最新討論串1/1
parameters='action=edit&section=new&title=hello&text=hello&format=xml&token=' + edittoken; 上面這是我send的parameter token是+\ 可是接收的頁面收到的卻是\\ 我有setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 然後我自己在這個頁面印出parameters是這樣 action=edit§ion=new&title=hello&text=hello&format=xml&token=+\ 好像是因為&sect會被當作那個符號 不過送過去section是有接收到 所以應該跟這沒有關係 token要怎麼樣才能正確的送過去呢? 用encodeURIComponent跟encodeURI編碼edittoken好像也不行 這個問題卡了我快一個星期了... ------------------------------------------------------------------------- 我在responsetext印出來的結果是這樣 <? echo $_POST['title'].'<br>'; echo $_POST['section'].'<br>'; echo $_POST['action'].'<br>'; echo $_POST['text'].'<br>'; echo $_POST['format'].'<br>'; echo $_POST['token'].'<br>'; ?> hello new edit hello xml \\ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.211.217.211 ※ 編輯: tn801534 來自: 218.211.217.211 (07/07 09:15) ※ 編輯: tn801534 來自: 218.211.217.211 (07/07 09:17) ※ 編輯: tn801534 來自: 218.211.217.211 (07/07 09:43)

07/07 09:46, , 1F
用encodeURIComponent函數把"+\\"編碼
07/07 09:46, 1F

07/07 09:46, , 2F
還有edittoken不能改喔...是系統產生的
07/07 09:46, 2F

07/07 09:48, , 3F
用encodeURIComponent收到的是+\\我送的是+\...
07/07 09:48, 3F

07/07 10:03, , 4F
把會出問題的用特定字串替換 到達後端之後再解碼
07/07 10:03, 4F

07/07 10:09, , 5F
可是後端的那個接收頁面事實上不能改說...所以我才用ajax
07/07 10:09, 5F

07/07 10:09, , 6F
特定字串是什麼意思?
07/07 10:09, 6F

07/07 10:34, , 7F
後端頁面不能改,送過去的字串又不合法,那可說就沒救了=.=a
07/07 10:34, 7F

07/07 10:37, , 8F
舉例: -> 把 \ 換成 %%1 到後端再把%%1 replace回 \
07/07 10:37, 8F

07/07 10:37, , 9F
諸如此類的作法,有時候碰到一些特別的字串又懶得找html
07/07 10:37, 9F

07/07 10:37, , 10F
escape word的時候就會這樣做
07/07 10:37, 10F
文章代碼(AID): #18SMuZJD (Ajax)
文章代碼(AID): #18SMuZJD (Ajax)