Home  >  Article  >  Backend Development  >  PHP 404 judgment and js 404 judgment

PHP 404 judgment and js 404 judgment

PHP中文网
PHP中文网Original
2016-08-08 09:30:451832browse

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)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn