I have created a customclientraw.txt and its working ok (for this tag anyway lol)
I have a new ajaxWDwx2.js (notice the 2)
I have added this path in the above file var clientrawFile = ‘…/customclientraw.txt’; its in the home dir
I have added this in the above file
The ajax script is designed to check the contents of the clientraw.txt file to make sure it has ‘12345’ at start and ‘!!’ at end of record
if not, it does not update.
inside ajaxWDwx2.js change:
// now make sure we got the entire clientraw.txt -- thanks to Johnnywx
// valid clientraw.txt has '12345' at start and '!!' at end of record
var wdpattern=/\d+\.\d+.*!!/; // looks for '!!nn.nn!!' version string
// If we have a valid clientraw file AND updates is < maxupdates
if(clientraw[0] == '12345' && wdpattern.test(x.responseText) &&
( updates <= maxupdates || maxupdates > 0 ) )
You’ll also need to change the name of the function ajaxLoader to another name (like ajaxLoader2) to prevent interference with the regular AJAX function in ajaxWDwx.js
Yes, both the function name itself, and all the function references … otherwise the ‘other’ function will be called instead
It doesn’t matter that other functions are duplicated, since they provide the same conversions/utility things used by both scripts, but the main script function and it’s invocations have to have a new name to differentiate it from the existing function name.
You can see a (massively complicated) version of the for the ajaxVWSwxf.js script (AJAX for a product-who’s-name-won’t-be-mentioned). That script has two ajaxLoaders, and a one-time loader to parse the units to use from a config file. It does show how to have 3 different ajax functions all coexist.
thanks alot, i done all that and its sort of working now, but it looks like its not using the
new customclientraw.txt file, its still using the original one, i must have forgotten something?
I assumed that changing this was all that was needed for the clientraw file?
var clientrawFile = ‘…/customclientraw.txt’;
You probably need to do a global replacement for ‘clientrawFile’ to be ‘clientrawFile2’ in your ajaxWDwx2.js so it doesn’t interfere with the ajaxWDwx.js definition of your ‘real’ clientraw file.
Also, remember to use the Absolute URI for the file name ‘/customclientraw.txt’ (if the file is uploaded by WD to your document root directory).
No… that would only be for PHP (which only knows about filesystem addresses).
The URI is the path part of the URL which the webserver uses… JavaScript only knows about website addresses, not filesystem addresses.
I think there both the same as they both find clientraw #1 anyway,
As for changing clientrawFile to clientrawFile2 has left the site with a wee issue #1 its slow loading now and #2, well see for yourself, the ajax has a problem lol http://www.northantsweather.com/weather/wxindex.php
That should work irrespective of what page loads it.
in your ajaxLoader2 function, you need to delete ALL the old function contents, and add in your new contents to decode the customclientraw.txt file. Also, you need to delete
// ------------------------------------------------------------------------------------------
// main function.. read clientraw.txt and format <span class="ajax" id="ajax..."></span> areas
// ------------------------------------------------------------------------------------------
function ajaxLoader2(url) {
if (document.getElementById) {
var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(url);
}
if (x) { // got something back
x.onreadystatechange = function() {
try { if (x.readyState == 4 && x.status == 200) { // Mike Challis added fix to fix random error: NS_ERROR_NOT_AVAILABLE
var clientraw = x.responseText.split(' ');
if ( updates <= maxupdates || maxupdates > 0 ) {
if (maxupdates > 0 ) {updates++; } // increment counter if needed
Delete everything after that down to
} // END if(clientraw[0] = '12345' and '!!' at end)
} // END if (x.readyState == 4 && x.status == 200)
} // END try
catch(e){} // Mike Challis added fix to fix random error: NS_ERROR_NOT_AVAILABLE
} // END x.onreadystatechange = function() {
x.open("GET", url, true);
x.send(null);
and add your new code in the space between the two code snippets.
You should also remove
// reset the flash colors, and restart the update unless maxupdate limit is reached
setTimeout("reset_ajax_color('')",flashtime); // change text back to default color
(since the ajaxWDwx.js will do that already)
and remove
//element = document.getElementById("ajaxcounter");
//if (element) {
window.setInterval("ajax_countup()", 1000); // run the counter for seconds since update
//}
Thanks again Ken, getting much closer now, well, the sites speeded up again and
i can now see some data, although, its not quite what i was expecting, its showing
Snow height as 341m but it should be at 1120m thats what the tag says in wd
I did pinch the cloud height code from the other ajax file and just changed the variables
But i have a feeling it thinks its in feet and its converting it to meters, does that sound
about right?
Thanks so much for helping me out…
Also thanks to everyone else that set me off in the right direction
I now have a base to work from, i now just need to get it all working
in the customclientraw file