>Given I have some content embedded on my page by calling a remote JS and
>occasionally the URL for the remote script is down causing my page to be
>slow or fail, can I use the following example as a means to test and timeout
>the remote server and skip the embedded JS, if the remote server isn't
>responding properly?

Mostly sorta...

>$fp = fsockopen ("www.theweathernetwork.com", 80, $errno, $errstr, 5);

What if, in between this line and the one below, their site dies?

Once you've bothered to fsockopen() to them, go whole hog and suck in the
data :-)

Otherwise, you are just doubling the number of HTTP connections used by your
page when it *DOES* work, and that's not good for performance.

>if (!$fp) {
>    echo "sorry, not available";
>}     else {
>    echo "<script language=\"JavaScript\" type=\"text/javascript\">
>          <!-- var city = \"Muskoka_ON\"; //-->
>          </script>
>          <script language=\"javascript\" type=\"text/javascript\"
>          src=\"http://www.theweathernetwork.com/weatherbutton/test.js\";>
>          </script>";
>    }
>TIA, verdon

Like Music?  http://l-i-e.com/artists.htm

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to