I used Construct to build a "dashboard" for accessing several device GUIs for a system I maintain. In short, it loads a page of buttons on a local machine which open browser windows to the respective device URLs when clicked - all of this works great.
I want to add an "online status" feature which changes a sprite's color for each device when the dashboard is launched (green = online, red = offline). In attempts to accomplish this, I have the program make an AJAX call to the respective devices when each button is created and will attempt to use the AJAX.onerror condition to set the status. (I realize I may have CORS issues, but that will be the next hurdle.)
The issue I am having is getting the AJAX.onerror condition to fire. It is not firing (I've tested with oncomplete, onprogress, etc, just in case there simply was no "error" being reported). I've even tried forcing an error with a bad URL and attempting to force a complete call by calling my own server which I know will respond.
My logic works like this:
The dashboard buttons (links) are created from a JSON file. When the button is created, it stores a unique identifier for that button (I'm using the URL that is in the JSON file for that device) in an instance variable for the "statusLED" sprite I create which is also used as the "tag" for that buttons's status AJAX call. (This ends up looking something like "schttp://xxx.xxx.xxx", "schttp://xxx.xxx.yyy", etc.)
Later on in the script - outside of the button-creation logic - I have a For Loop that cycles through all of the "statusLED" sprites on the page and for each of them, I am checking the AJAX onError and using that "statusLed" sprite's instance variable in the "tag" field. The idea here is that the default "statusLed" is green (sprite frame 1) and if an AJAX error occurs (no response from server device) it will set the frame to red (frame 0). I've tried "onComplete", "onanyErrors", "onanyComplete" just to see if I was simply not getting an error, but those never fire either.
To test whether or not it is firing, I have the value of the instance variable for each "statusLED" sprite appended to a text field but it doesn't happen. When I move this "append" action outside of the onError block and just inside the For Loop, the instance variables populate the box - so I know the issue is not in the setting / recalling of the tag names.
Any ideas what I am getting wrong here? Is the AJAX.onError not inside the ForLoop? (and if not, how else can I check multiple independent Ajax calls?)
I have other AJAX calls to pull data in from my JSON files in other parts of the script and they are working just fine.
(I only recently added the "statusCheck" condition as I realized this section was looping continuously - didn't help. - Also not exactly sure if the For Loop executed before the "statusCheck" var is set to 1.)
Thank you in advance!