Author Topic: Nother script issue/question  (Read 2677 times)

0 Members and 1 Guest are viewing this topic.

Offline aadamson

  • Member
  • *
  • Posts: 14
    • N1IP's Live Weather
Nother script issue/question
« on: November 02, 2007, 09:40:05 PM »
Ok, this one is a complex one, but I hope someone has a good idea of what to do...

http://www.maxwinds.com/index.htm - the problem page

Ok, here's a good one for you...the real issue is, how come the ajax stuff stops working... If you go to the link above you'll see that Monthly rain, and Daily rain (on the last rain row about 2/3's the way down) only show "in", thats all they will produce and yet they won't update or show the 0.0 which is what is in the clientraw file.

However, if you run the version at http://www.maxwinds.com/ajax-testpage.php, those fields update.  (these both use the same ajax javascript routines in Ken's orginal distribution.

I copied and pasted the exact same code from Ken's samples into my index.htm file and you can see that it works for everything up to those last 2 variables.

I've scratched my head now for a week trying to figure this out before I go any further.  It's like it's failing to find the <span> tag for those last two.

Anyone got any good debugging tools or suggestions?

I just don't get it, the format is all complete, I've run this thru many validators, there seems to be no missing semi-colons, etc.  But those last 2 just won't work...  I've even hard coded values in the javascript just to see if there were other problems and they still won't update.  And yes, I've even manually changed the rain values to something other than zero to see if that would fix it and it doesn't :(...

I'm perplexed.

Alan

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6740
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Nother script issue/question
« Reply #1 on: November 02, 2007, 10:49:42 PM »
I think you've encountered the seldom mentioned limitation about id="" tags.. there can only be one uniquely named instance per HTML page.

You have 3 instances of id="ajaxrainratehr" marked, and a couple of id="ajaxrain" marked also.

If you want to have the same AJAX data appear multiple places on your page, then you'll need to create unique id= for each one and clone the code in ajaxWDwx.js to support the new id= variables.

Example, for daily rain (id="ajaxrain"), you can change
Code: [Select]
//Rain ...
rain = convertRain(clientraw[7]);
set_ajax_obs("ajaxrain",rain.toFixed(dpRain) + uomRain);
to
Code: [Select]
//Rain ...
rain = convertRain(clientraw[7]);
set_ajax_obs("ajaxrain",rain.toFixed(dpRain) + uomRain);
set_ajax_obs("ajaxrain2",rain.toFixed(dpRain) + uomRain);
set_ajax_obs("ajaxrain3",rain.toFixed(dpRain) + uomRain);
which will create three instances for you to use. 

After changing ajaxWDwx.js, then change the markup on your page to use the new id= in your span tags.  Doesn't matter what order they're specified in for the code or the page, they just have to be unique on the page  :grin:

Hope this helps...

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

Offline aadamson

  • Member
  • *
  • Posts: 14
    • N1IP's Live Weather
Re: Nother script issue/question
« Reply #2 on: November 02, 2007, 11:09:25 PM »
duh.... OMG... I'm the one that asked that the first time too... And I *totally* forgot that I used those at the top of the page.... sheesh!

Ok, now do I feel dumb or what.... Guess that's what I get for looking at this stuff too long and too many times...


Sheesh

thanks,
Alan - who's walking away - tail between his legs... :)

Offline aadamson

  • Member
  • *
  • Posts: 14
    • N1IP's Live Weather
Re: Nother script issue/question
« Reply #3 on: November 02, 2007, 11:14:55 PM »
All fixed... now you can be sure that I won't make that mistake again... And to think this is the second time! :)...

Thanks all for the efforts, time, etc

Alan

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 6740
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Nother script issue/question
« Reply #4 on: November 03, 2007, 12:53:58 AM »
You're very welcome!

That particular 'gotcha' has struck me too.  You can have any number of class= markups with the same value on a page (and that's why the class="ajax" is used to support the 'green flash' on conditions change), but only one id= value on a page.  ](*,)

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