| Author |
Message |
discofreakboot
Joined: 09 Sep 2006 Posts: 4
|
| Posted: Mon Oct 16, 2006 - 12:20 pm Post subject: Refreshing |
|
|
Hey.
I made a widget that uses <script src="blah"> in order to retrieve information from a website. But I don't know how to make it reload that remote script every time I launch Dashboard.
Can anybody help? |
|
| |
|
| |
filipp
Joined: 16 Apr 2006 Posts: 24
|
| Posted: Mon Oct 16, 2006 - 2:46 pm Post subject: |
|
|
First wrap your code into a function, like "getInfo()" and then just attach that as the widget.onshow event handler like so:
| Code: |
widget.onshow = getInfo;
|
Now every time widget is shown on the Dashboard, the function is run. |
|
| |
|
| |
discofreakboot
Joined: 09 Sep 2006 Posts: 4
|
| Posted: Mon Oct 16, 2006 - 2:50 pm Post subject: What? |
|
|
How do I make that retrieve the information from the script on a remote server each time?
The script it brings in with <script src="">, that's on a web server. How do I make it retrieve the script again with the new information? |
|
| |
|
| |
filipp
Joined: 16 Apr 2006 Posts: 24
|
| Posted: Mon Oct 16, 2006 - 2:53 pm Post subject: |
|
|
| You mean how to reload a page? Are you using XMLHttpRequest? just send another request? |
|
| |
|
| |
discofreakboot
Joined: 09 Sep 2006 Posts: 4
|
| Posted: Mon Oct 16, 2006 - 2:57 pm Post subject: |
|
|
I have absolutely no idea how to use XMLHttpRequest. Is there a straight-forward tutorial somebody could point me to?
But my current widget works this way:
A PHP script on the server grabs info from a database and then basically does this...
<?php
header('content-type: text/javascript');
echo 'var1 = "'.$var1.'";
var2 = "'.$var2.'";';
?>
So the information is updated in this script file. |
|
| |
|
| |
filipp
Joined: 16 Apr 2006 Posts: 24
|
|
| |
|
| |