at51178
01-08-2008, 07:23 PM
Hi
I am working on a project that would go out and retrieve specific content from websites through the req.open("get",url,false) method. The script loops through an array of stock symbols and retrieves information from the url specified.
So far the script works great, it does everything I want it to do, except one thing
Since I am going to be working with a lot of stock symbols there will be some symbols the website does not have on their database and it seems that every time I come across a symbol that is not on their database the script just stops.
below is the script I am working on and if you look at my array you will notice a stock symbol named "aa.p", even though it is a valid symbol the website from which I am retrieving information from does not contain that symbol.
I am not sure where the problem is, you may first want to remove the symbol "aa.p" and run the script to see it work and then add the symbol "aa.p" to the array and you will see the issue I am facing.
Here is the below code.
var req = new ActiveXObject("Microsoft.XMLHTTP");
var mysymbol = new Array()
mysymbol[0] = "goog";
mysymbol[1] = "diod";
mysymbol[2] = "aa.p";
mysymbol[3] = "hal";
mysymbol[4] = "ppdi";
function getdata()
{
for (var i = 0; i < mysymbol.length; i++)
{
req.open("GET", "http://quote.barchart.com/texpert.asp?sym=" + mysymbol, false);
handleResponse(i)
}
}
function handleResponse(i)
{
req.send(null);
if(req.readyState == 4)
{
if(req.status == 200)
{
document.write(mysymbol + " " + req.responseText.length + " valid <p>")
}
else
{
document.write(mysymbol + " invalid <p>")
}
}
}
I am working on a project that would go out and retrieve specific content from websites through the req.open("get",url,false) method. The script loops through an array of stock symbols and retrieves information from the url specified.
So far the script works great, it does everything I want it to do, except one thing
Since I am going to be working with a lot of stock symbols there will be some symbols the website does not have on their database and it seems that every time I come across a symbol that is not on their database the script just stops.
below is the script I am working on and if you look at my array you will notice a stock symbol named "aa.p", even though it is a valid symbol the website from which I am retrieving information from does not contain that symbol.
I am not sure where the problem is, you may first want to remove the symbol "aa.p" and run the script to see it work and then add the symbol "aa.p" to the array and you will see the issue I am facing.
Here is the below code.
var req = new ActiveXObject("Microsoft.XMLHTTP");
var mysymbol = new Array()
mysymbol[0] = "goog";
mysymbol[1] = "diod";
mysymbol[2] = "aa.p";
mysymbol[3] = "hal";
mysymbol[4] = "ppdi";
function getdata()
{
for (var i = 0; i < mysymbol.length; i++)
{
req.open("GET", "http://quote.barchart.com/texpert.asp?sym=" + mysymbol, false);
handleResponse(i)
}
}
function handleResponse(i)
{
req.send(null);
if(req.readyState == 4)
{
if(req.status == 200)
{
document.write(mysymbol + " " + req.responseText.length + " valid <p>")
}
else
{
document.write(mysymbol + " invalid <p>")
}
}
}