MozillaZine

XmlHttpRequest syntax error

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

Post Posted April 11th, 2014, 9:10 am

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?

Return to Mozilla Development


Who is online

Users browsing this forum: No registered users and 1 guest