How do I evaluate if a web service is running?

7132
22
05-11-2015 08:02 AM
ChrisSergent
Regular Contributor III

Before my code runs, I would like to evaluate if a web service is running. How would I do that in JavaScript?

Tags (2)
0 Kudos
22 Replies
OwenEarley
Occasional Contributor III

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");

ChrisSergent
Regular Contributor III

I still get the 500, but simply as an error. It's not writing to the console.

0 Kudos
ChrisSergent
Regular Contributor III

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.