GET请求错误,未捕获的SyntaxError:意外的标识符OPTIONS

时间:2013-03-01 18:16:55

标签: php javascript http get xmlhttprequest

发送get请求时,我似乎遇到了一个非常奇怪的错误,我正在运行这两个错误 PHP和javascript代码在同一台服务器上,所以没有原因问题。错误:

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 个答案:

答案 0 :(得分:1)

试试这个:

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