Author Topic: Javascript to pull in weather advisory  (Read 1573 times)

0 Members and 1 Guest are viewing this topic.

Offline muchgooder.com

  • Member
  • *
  • Posts: 38
Javascript to pull in weather advisory
« on: September 11, 2009, 10:02:17 AM »
I have the php weather software installed on my site and that is working fine.  At this point I would like to populate a div area on my non-php homepage where I can pull in a weather advisory if there is one for my area.  Weather Display provides the xml file so I believe that this is an operation of parsing that file in javascript.  Is anyone aware of a script to do this?

Here is a sample file from my site:  http://www.muchgooder.com/weather/wd/rss-advisory-NYZ001x.txt

Online saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9257
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Javascript to pull in weather advisory
« Reply #1 on: September 11, 2009, 11:24:59 PM »
You might find a JavaScript you like for RSS feeds at DynamicDrive .. there are lots to choose, and all JavaScript/DHTML

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline WeatherHost

  • Forecaster
  • *****
  • Posts: 3649
Re: Javascript to pull in weather advisory
« Reply #2 on: September 12, 2009, 06:24:43 AM »
Look into "Server Side Includes": http://en.wikipedia.org/wiki/Server_Side_Includes

There are a zillion other pages also to help you configure them if you do a web search for the term.

Since you have some php working that means your host supports it.  You set up a separate, non-public page to pull in the advisory, then use the SSI to echo the resulting text on your main page.

It may be something that would work for you.

Also, look at CarterLake's PHP NOAA Advisory Text script on this page:  http://www.carterlake.org/weatherphp.php

The script is configurable for your specific location.


Offline muchgooder.com

  • Member
  • *
  • Posts: 38
Re: Javascript to pull in weather advisory
« Reply #3 on: September 13, 2009, 06:10:19 PM »
Thank you both very much. 

Ken, I was not aware of those ready-made functions.

I think the easiest thing to do is to to the server-side include (I'm already doing it with thermometer.php on my home page).  The problem I'm having with that is that I only want the php to display if there is an advisory.  Otherwise, I'd like something else (non-php) to display in that area as it does now.  Is there a way to test for the advisory before doing the include?  I'm thinking that the easy way would be to parse the value of the advisory file unless someone knows a way to do this with php.