Dylan Katz
Dylan Katz

Reputation: 194

GET Request error, Uncaught SyntaxError: Unexpected identifier OPTIONS

I appear to be getting a very strange error when sending a get request, I am running both the PHP and the javascript code on the same server, so no origin problems. Errors:

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

on this line:

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

My full code:

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);
    }
}

Upvotes: 1

Views: 785

Answers (1)

karaxuna
karaxuna

Reputation: 26930

Try this:

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

Upvotes: 1

Related Questions