i want simulate server side something so:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
document.write(unescape("%3Cscript src='/Scripts/jquery-1.3.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
And so, i have in php:
function isurlok($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
if(!curl_errno($ch))
$info = curl_getinfo($ch);
curl_close($ch);
if (isset($info) && $info['http_code'] == 200) {
if ($info['http_code'] == 200 ) {
return true;
} else {
return false;
}
} else {
return false;
}
}
For get the available of the resource (in this case the file) and then this:
if ( isurlok ("https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js") {
// remote file
print "<script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>";
print "remote file";
} else {
// local file
print "<script type=\"text/javascript\" src=\"jquery/1.11.3/jquery.min.js\"></script>";
print "local file";
}
Why it not work? I mean that script return "local file" when remote file exists and i wait that return "remote file". If i change url of Google with: "http://ajax.microsoft.com/ajax/jquery/jquery-1.3.2.min.js" then it work correctly. Where i mistake? And in case, how i can fix the script becouse it work Always? Thanks very much.