2013-03-01 98 views
1

發送獲取請求時,我似乎遇到了一個非常奇怪的錯誤,我在同一臺服務器上運行了PHP和javascript代碼,因此沒有原始問題。錯誤:GET請求錯誤,未捕獲SyntaxError:意外標識符選項

Uncaught SyntaxError: Unexpected identifier 
OPTIONS http://localhost/Scores.php 
Uncaught SyntaxError: Unexpected identifier 

在這條線:

 req.send("&name="+username+"&pw="+password); 

我全碼:

function initiateLoginSequence() { 
    var isnewplayer=prompt("Hello! Are you new?(Y/N)"); 
    if(isnewplayer == "N") { 
     var username = prompt("Enter username."); 
     var password = prompt("Enter Password."); 
    } else { 
     var username = prompt("Enter a username. This will be used for future logins."); 
     var password = prompt("Enter a password. This will be used for future logins.","*"); 
     var req = new XMLHttpRequest(); 
     req.open('GET', 'http://localhost/Scores.php', true); 
     req.send("&name="+username+"&pw="+password); 
    } 
} 
+1

可能不是回答你的問題。但注意到你正在調用'send()'兩次。 – techfoobar 2013-03-01 18:18:22

回答

1

試試這個:

req.open('GET', 'http://69.144.34.106/Scores.php?name='+username+'&pw='+password, true); 
req.send(); 
+0

非常感謝! – 2013-03-01 20:46:31

+0

歡迎您:) – karaxuna 2013-03-01 20:48:03

相關問題