Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

Post new topic   Reply to topic Posted in: Widget Development

Refreshing

Author Message
discofreakboot



Joined: 09 Sep 2006
Posts: 4

Posted: Mon Oct 16, 2006 - 12:20 pm    Post subject: Refreshing Reply with quote

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?
View user's profile Send private message Send e-mail AIM Address Widgets
filipp



Joined: 16 Apr 2006
Posts: 24

Posted: Mon Oct 16, 2006 - 2:46 pm    Post subject: Reply with quote

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.
View user's profile Send private message Send e-mail Widgets
discofreakboot



Joined: 09 Sep 2006
Posts: 4

Posted: Mon Oct 16, 2006 - 2:50 pm    Post subject: What? Reply with quote

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?
View user's profile Send private message Send e-mail AIM Address Widgets
filipp



Joined: 16 Apr 2006
Posts: 24

Posted: Mon Oct 16, 2006 - 2:53 pm    Post subject: Reply with quote

You mean how to reload a page? Are you using XMLHttpRequest? just send another request?
View user's profile Send private message Send e-mail Widgets
discofreakboot



Joined: 09 Sep 2006
Posts: 4

Posted: Mon Oct 16, 2006 - 2:57 pm    Post subject: Reply with quote

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.
View user's profile Send private message Send e-mail AIM Address Widgets
filipp



Joined: 16 Apr 2006
Posts: 24

Posted: Mon Oct 16, 2006 - 3:08 pm    Post subject: Reply with quote

In other words how to access information from other pages?
Please check FAQ point 2.3:
http://www.dashboardwidgets.com/forums/viewtopic.php?t=831
View user's profile Send private message Send e-mail Widgets
Post new topic   Reply to topic

 
Powered by phpBB © 2001, 2002 phpBB Group