PHP 404 judgment and js 404 judgment
php judgment 404:
$url = home_url()."/wp-content/themes/twentythirteen/pic/".$result['pic']; $headers = @get_headers($url); if(strpos($headers[0],'404') ) { $url=home_url()."/wp-content/themes/twentythirteen/pic/default.png"; }
js judgment 404:
var pic_url ="/wp-content/themes/twentythirteen/pic/"+data[i].pic; $.ajax({ url:pic_url, error:function(xhr, error, ex){ if (xhr.status == '404') { pic_url = "/wp-content/themes/twentythirteen/pic/default.png"; } }, success:function(){ pic_url = pic_url; } });
js judgment 404, through ajax...
The above introduces PHP 404 judgment and js 404 judgment, including relevant content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!