I am working on a very simple sidebar gadget to analyze the monthly usage of the router’s bandwidth and determine how far forward or backward I am for this month. The data is located on a password-protected web page on the router (I use DD-WRT, if that matters). I would like to send the page request to the router using Javascript along with all the authentication information in order to get the whole page in one go, but I cannot find the appropriate syntax for this. Any ideas?
Here is my code:
var ua = navigator.userAgent.toLowerCase();
if (!window.ActiveXObject){
req = new XMLHttpRequest();
}else if (ua.indexOf('msie 5') == -1){
req = new ActiveXObject("Msxml2.XMLHTTP");
}else{
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open('GET', 'http://192.168.1.1/Status_Internet.asp', false, "username", "password");
req.send(null);
if(req.status == 200){
dump(req.responseText);
} else{
document.write("Error");
}
document.write("Second Error");
Firebug indicates that it is an error at req.send(null)- in particular
Access to restricted URI denied" code: "1012.
- , , xmlhttpRequest?