PHP 404 judgment and js 404 judgment

PHP中文网
Release: 2016-08-08 09:30:45
Original
1892 people have browsed it

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";
	}
Copy after login


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;
				}
			});
Copy after login


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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!