2012-02-24 65 views
0

除了Opera瀏覽器之外,我可以使用來自所有瀏覽器的HttpRequest將數據發送到服務器。我也厭倦了歌劇11.61。但我仍然不能從歌劇browser.My代碼發送數據的服務器是不能從Opera瀏覽器使用HttpRequest發送數據

xmlHttp=new XMLHttpRequest(); 
var url="http://localhost"; 
xmlHttp.open("POST",url,true); 
var params = "lorem=ipsum&name=binny"; 
function timerMethod() 
{ 
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
xmlHttp.setRequestHeader("Content-length", params.length); 
xmlHttp.send(params); 
} 

請幫我在這個問題上

與問候, Muthu.S

+1

我想我們需要看到更多的代碼。特別是,timerMethod()從哪裏調用?有沒有控制檯錯誤?這段代碼也在http:// localhost頁面上運行,對吧? – hallvors 2012-02-28 10:29:31

回答

0

這應該工作只要你撥打timerMethod()從代碼中的其他地方,暗示着hallvors。例如:

xmlHttp=new XMLHttpRequest(); 
var url="http://localhost/stackoverflow/response.php"; 
xmlHttp.open("POST",url,true); 
var params = "lorem=ipsum&name=binny"; 
function timerMethod() 
{ 
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 
    xmlHttp.setRequestHeader("Content-length", params.length); 
    xmlHttp.send(params); 

    xmlHttp.onload = function(){ 
     console.log(this.responseText); 
    } 
} 

timerMethod(); 
相關問題