Check if a remote site is online using AJAX?
ajax, curl, javascript, jquery, php
Solution
If the site is remote, there are many chances you won't be able to achieve it with javascript due to the Same Origin Policy.
However, in php, you could make only a HEAD request so it doesn't load contents so it will be much, much faster.
Hope this helps. Cheers
Problem
My site checks 5 different URLs using PHP's cURL to tell if they're online. The problem is that it takes too long to load the page (especially if one of the sites it's checking is down). I hear jQuery's ajax would work well, so I tried this code: ``` <div class="alert alert-info" id="forum-blockland-us"><b>Checking...</b></div> <script> $.ajax({ type: "GET", url: "http://forum.blockland.us/", cache:false, success: function() { $("#forum-blockland-us").addClass("alert-success"); $("#forum-blockland-us").removeClass("alert-info"); $("#forum-blockland-us").html("<b>Online</b>"); }, error: function() { $("#forum-blockland-us").addClass("alert-danger"); $("#forum-blockland-us").removeClass("alert-info"); $("#forum-blockland-us").html("<b>Offline</b>"); } }); </script> ``` But it always returns the error, even when I know 100% that the sites are online.