Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Central

Trying to fetch a number from a Text File on the net

Author Message
JohnGaver



Joined: 17 May 2005
Posts: 20
Location: Texas

Posted: Thu May 26, 2005 - 1:31 am    Post subject: Trying to fetch a number from a Text File on the net Reply with quote

I am trying to take the text of a plain text file on the internet and place that into a variable that will be placed in a widget, every so often, but I can't remember how to get the data from the web into a var.

The text file will be three digits, with no following carriage return. It will look like:

Quote:
012


The url will be of the form:

Quote:
http://www.mysite.com/number.txt


I want to place the numbers in that text file into a variable and display it in a span, as follows:

Quote:
document.getElementById("webNumber").innerText = getWebNumber();


The only problem is that I can't remember how to get the number in the file on the web (123), to be returned from the function getWebNumber(). I'm having trouble creating the function getWebNumber(). I know that it's simple, but I think that I am having a senior moment. Any ideas?

BTW, this number will be fetched from the net every 5 minutes or so. I can make that happen easy. It's just the url stuff that I am having trouble with. If the data in the text file changes to 456, then the widget should change it's display to 456, on the next update.

Thanks in advance.
View user's profile Send private message Send e-mail Visit poster's website Widgets
andrethegiant



Joined: 08 May 2005
Posts: 78

Posted: Fri Jun 17, 2005 - 10:58 am    Post subject: Reply with quote

You need to use xmlhttprequest and regualr expression. this can get any off of any website or local file. Search for xmlhttprequest on these forums or on google, and that should get your results. Your regualr expression should look like this:
Code:

var number = /[\d]+/


Hope that helps!
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group