XmlHttpRequest syntax error

Discuss building things with or for the Mozilla Platform.
Post Reply
chucke1992
Posts: 5
Joined: April 2nd, 2014, 10:04 am

XmlHttpRequest syntax error

Post by chucke1992 »

I'm trying to make GET request to server.
But browser shows syntax error

Code: Select all

req.open('GET','http://localhost:9998/main.xul?sendID=id&action=test&param=p', true);
---------------------------------------------------------------^

My function looks like this

Code: Select all

function sendData(sendID)
{
    var p = document.getElementById('idtxb').value;
    var req = new XMLHttpRequest();
    req.open('GET','http://localhost:9998/main.xul?sendID=id&action=test&param=p', true);
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.status == 200) {
                document.getElementById('idtxb').value = req.responseText;
            }
            if (req.status == 404) {
                alert('Something is wrong!');
            }
        }
    };
    req.send();
};

What is wrong and what is the correct way to pass parameters?
Post Reply