AJAX Question

I’m running a custom AJAX PHP main page on my site. I still haven’t figured
out all this AJAX Stuff. Anyway, I have Low Wind chill on there. Whats the
procedure for making that into a 5 second updating variable like the wind chill,
temp and all the other items.

I’ve putzed around and cant seem to figure it out yet.
Plus I’d like to add other things eventually.

Thanks, Tony!


Hmmm that Ajax code is different from what I’ve played with but… it appear you can add it like:

` // FeelsLike
temp = x.responseText.split(’ ‘)[4];
if (temp <= 16.0 ) {
feelslike = x.responseText.split(’ ‘)[44]; //use WindChill
} else if (temp >=27.0) {
feelslike = x.responseText.split(’ ‘)[112]; //use Heat Index
} else {
feelslike = x.responseText.split(’ ')[4]; // use temperature
feelslike = (1.8 * feelslike) + 32.0;
set_ajax_obs(“ajaxfeelslike”,feelslike.toFixed(1) + " °F");

[b] // Add winchil hi/low values
winchilhi = x.responseText.split(’ ‘)[77];
winchillo = x.responseText.split(’ ')[78];

            set_ajax_obs("ajaxwinchhi", winchilhi.toFixed(1) + " &deg;F");
            set_ajax_obs("ajaxwinchlo", winchillo.toFixed(1) + " &deg;F");[/b]`

Then you would wrap your Wind Chill Low tag with the class=“ajax” and id=“ajaxwinchlo”

That code is Tom from Carter Lake’s creation last year.

I’m still learning. Cant get it working just yet.

Added the windchill hi and low values here:

                // FeelsLike
                temp = x.responseText.split(' ')[4];
                if (temp <= 16.0 ) {
                        feelslike = x.responseText.split(' ')[44]; //use WindChill
                } else if (temp >=27.0) {
                        feelslike = x.responseText.split(' ')[112]; //use Heat Index
                } else {
                        feelslike = x.responseText.split(' ')[4];  // use temperature
                feelslike  = (1.8 * feelslike) + 32.0;
                set_ajax_obs("ajaxfeelslike",feelslike.toFixed(1) + " &deg;F");
                // Add winchil hi/low values
                winchilhi = x.responseText.split(' ')[77];
                winchillo = x.responseText.split(' ')[78];

Changed my code to this:

<tr class="column-dark">
<td align="center" style="height: 31px; width: 19%;"><span style="font-size: 14px;"><b><?echo $feelsText?>
<span name="ajax" id="ajaxfeelslike"></span><noscript></noscript></b>
<td align="center" <div style="font-size: 12px;">Low Wind Chill: <?php if ($liveoff == 1) {echo $wxdata[12];} else {echo '<span name="ajax" id="ajaxwinchillo"></span><noscript>'; echo $wxdata[12]; echo '</noscript>';} ?>
<td align="center" style="width: 22%"><span style="font-size: 14px;"><b>Dew Point:</b>
 <b><?php if ($liveoff == 1) {echo $wxdata[4];} else {echo '<span name="ajax" id="ajaxdew"></span><noscript>'; echo $wxdata[4]; echo '</noscript>';} ?>


Thats what I’ve put in place of what I had before. If the page is live, nothing shows.
If I change it to static and no 5 second updates, its there.



Looks like you were missing the set_ajax_obs values…

So, you were creating them, but then not passing them into the page.

So how do I figure out what the set_ajax_obs values should be.

// Add winchil hi/low values
                winchilhi = x.responseText.split(' ')[77];
                winchillo = x.responseText.split(' ')[12];
                set_ajax_obs("ajaxwinchillo", ??  " &deg;F")


Kevin had it correct in his post above:

                // Add winchil hi/low values
                winchilhi = x.responseText.split(' ')[77];
                winchillo = x.responseText.split(' ')[78];
                set_ajax_obs("ajaxwinchhi", winchilhi.toFixed(1) + " &deg;F");
                set_ajax_obs("ajaxwinchlo", winchillo.toFixed(1) + " &deg;F");

although, to keep in the spirit of having optional units and supporting metric, it should probably read:

                // Add winchil hi/low values
                winchilhi = convertTemp(clientraw[77]);
                winchillo = convertTemp(clientraw[78]);
                set_ajax_obs("ajaxwinchhi", winchilhi.toFixed(1) + uomTemp);
                set_ajax_obs("ajaxwinchlo", winchillo.toFixed(1) + uomTemp);

You should update to the latest version of ajaxWDwx.js to do the latter code change.

Best regards,

#-o I’d forgotten that the current ajaxWDwx.js already has tags for windchill min/max (along with heat index min/max, dew point min/max, humidex min/max)

		//Dewpoint ...
		dew = convertTemp(clientraw[72]);
		set_ajax_obs("ajaxdew",dew.toFixed(1) + uomTemp);
		dewmin = convertTemp(clientraw[139]);
		set_ajax_obs("ajaxdewmin",dewmin.toFixed(1) + uomTemp);
		dewmax = convertTemp(clientraw[138]);
		set_ajax_obs("ajaxdewmax",dewmax.toFixed(1) + uomTemp);

		// Humidex
		humidex = convertTemp(clientraw[45]);
		set_ajax_obs("ajaxhumidex",humidex.toFixed(1) + uomTemp);
		humidexmin = convertTemp(clientraw[76]);
		set_ajax_obs("ajaxhumidexmin",humidexmin.toFixed(1) + uomTemp);
		humidexmax = convertTemp(clientraw[75]);
		set_ajax_obs("ajaxhumidexmax",humidexmax.toFixed(1) + uomTemp);

		//  WindChill
		windchill = convertTemp(clientraw[44]);
		set_ajax_obs("ajaxwindchill",windchill.toFixed(1) + uomTemp);
		windchillmin = convertTemp(clientraw[78]);
		set_ajax_obs("ajaxwindchillmin",windchillmin.toFixed(1) + uomTemp);
		windchillmax = convertTemp(clientraw[77]);
		set_ajax_obs("ajaxwindchillmax",windchillmax.toFixed(1) + uomTemp);

		// Heat Index
		heatidx = convertTemp(clientraw[112]);
		set_ajax_obs("ajaxheatidx",heatidx.toFixed(1) + uomTemp);
		heatidxmin = convertTemp(clientraw[111]);
		set_ajax_obs("ajaxheatidxmin",heatidxmin.toFixed(1) + uomTemp);
		heatidxmax = convertTemp(clientraw[110]);
		set_ajax_obs("ajaxheatidxmax",heatidxmax.toFixed(1) + uomTemp);

So no ajaxWDwx.js code change is necessary… you just need to use different <span id=> to use these built-in ones:

for the min windchill
for the max windchill

Best regards,


I’ll be playing around with it tonight. The .php AJAX stuff confuses me a bit.
I was playing with the HTML AJAX yesterday out of frustration.

Thanks again! :smiley: