response code 0 getting JSON from a website
<p>i am having a problem with the below code , it whenever i would try to request a the JSON data from the website , i would always get back a response code 0. Does anyone know why? If i were to go the website i would get the data just by inputting the correct login information.</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head&gt;
    &lt;title&gt;&lt;/title&gt;
    &lt;script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt;
    &lt;script src="Base64.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;

        function alertContents(HTTPobj) {

            if (HTTPobj.readyState == 4) {
                // everything is good, the response is received
                if ((HTTPobj.status == 200) || (HTTPobj.status == 0)) {
                    // FIXME: perhaps a better example is to *replace* some text in the page.
                    var htmlDoc = document.createElement('div'); // Create a new, empty DIV node.
                    htmlDoc.innerHTML = HTTPobj.responseText; // Place the returned HTML page inside the new node.
                    alert("The response was: " + HTTPobj.status + HTTPobj.responseText);
                    //var jsonData = eval('(' + HTTP.responseText + ')');
                    //parseJson(HTTP.responseText);

                }
                else {
                    alert('There was a problem with the request. ' + HTTPobj.status + HTTPobj.responseText);
                }
            }
        }


        }

        function makeBaseAuth(user,password) {
            var tok = user + ':' + password;
            var hash = Base64.encode(tok);
            alert(hash);
            return "Basic " + hash;
        }

        function getInput() {

            var getUser = document.input.user.value;
            var getPass = document.input.pass.value;
            var logData = makeBaseAuth(getUser, getPass);
            var url = 'http://www.tt-galaxi.com/thubrest/login';
            //  var url = 'http://www.tt-galaxi.com/thubrest/users/%@/trips',username;
            //    var url = 'http://www.tt-galaxi.com/thubrest/parkingbays';
            var HTTPobj = new XMLHttpRequest();
            HTTPobj.onreadystatechange = function () { alertContents(HTTPobj); };
            var test = HTTPobj.open('GET', url);
            HTTPobj.setRequestHeader('Authorization', logData);
            HTTPobj.send();

        }



    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;

    &lt;form name="input" action=""&gt;
    Username: &lt;input type="text" name="user" /&gt;
    &lt;br /&gt;
    Password:&lt;input type="text" name="pass" /&gt;    
    &lt;br /&gt;
    &lt;input id="Button1" type="button" value="Submit"  onclick="getInput()"/&gt;
    &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>
