Re: [問題] Firefox XMLHttp POST遇到的問題

看板Ajax作者 (充實自己實現夢想)時間14年前 (2011/02/24 22:20), 編輯推噓0(005)
留言5則, 2人參與, 最新討論串2/2 (看更多)
firefox用POST傳資料時 要設定MIME TYPE 可參考這篇文章 https://developer.mozilla.org/en/AJAX/Getting_Started 於是修改如下 ※ 引述《mhsu2k9 (mhsu2k9)》之銘言: var postData = "A=1&B=2&C=3&D=4"; //POST的參數 if(window.ActiveXObject){ var xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP"); }else{ var xmlhttp2 = new XMLHttpRequest(); } xmlhttp2.onreadystatechange=state_Change2; xmlhttp2.open("POST",postUrl,true); xmlhttp2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp2.send(postData); function state_Change2(){ if(xmlhttp2.readyState==4){ //200=OK if(xmlhttp2.status==200){ alert("Post OK_"); } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.248.90.133 ※ 編輯: mhsu2k9 來自: 60.248.90.133 (02/24 17:11) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.25.44.141

02/25 23:00, , 1F
我其實試過加入這一行文字,但是結果還是一樣
02/25 23:00, 1F

02/25 23:01, , 2F
不知firefox在傳送資料上,跟其它瀏覽器有何不同
02/25 23:01, 2F

02/26 00:53, , 3F
檢查你的request body在不同瀏覽器是否有差別,
02/26 00:53, 3F

02/26 00:53, , 4F
var xmlhttp2 = null; 這個先宣告在if外面試試...
02/26 00:53, 4F

02/26 00:56, , 5F
state_Change2中, 那個xmlhttp2盡量改用this比較好
02/26 00:56, 5F
文章代碼(AID): #1DPcay_E (Ajax)
文章代碼(AID): #1DPcay_E (Ajax)