Before my code runs, I would like to evaluate if a web service is running. How would I do that in JavaScript?
The above approach should work - see this live example: ESRI Service Test
Note that I also add your server in the esri.config so you don't get other CORS errors:
esri.config.defaults.io.corsEnabledServers.push("maps.decaturil.gov");
I still get the 500, but simply as an error. It's not writing to the console.
To evaluate if a layer if any web services are not running, you would enter the following code:
app.map.on("layer-add-result", function (evt) { console.log(evt); var testValue = evt.layer.valueOf(); if (testValue._div == null) { /* Page Redirect */ window.location.assign("http://www.w3schools.com") } });
You may not need app for your application.