Home » Categories » Multiple Categories

Hidden image after redirect by check filename

$("img.class").load(function() {
var noImage = this.src;
var xhr;
var _orgAjax = jQuery.ajaxSettings.xhr;
jQuery.ajaxSettings.xhr = function () {
xhr = _orgAjax();
return xhr;
};
$.ajax({
type: "GET",
url: noImage,
success: function(data) {
console.log(xhr.responseURL);
if (xhr.responseURL == 'https://www.domain.com/folder/noimage.jpg') {
$(".class").hide();
}
}
});
});
*/
var xhr = new XMLHttpRequest();
xhr.open('GET', 'https://www.domain.com/folder/theimage.jpg', true);
xhr.onload = function () {
console.log(xhr.responseURL);
//if (xhr.responseURL == 'https://www.domain.com/folder/noimage.jpg') {
var noimage = new RegExp("noimage");
if (noimage.test(xhr.responseURL)) {
$(".class").hide();
}
};
xhr.send(null);

Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
Attribute Contains Selector [name*=”value”]
Viewed 895 times since Wed, Sep 30, 2020
How to apply style to parent if it has child with CSS?
Viewed 583 times since Thu, Oct 8, 2020
Check image width and height before upload with Javascript
Viewed 528 times since Mon, Sep 21, 2020
jQuery multiple events to trigger the same function
Viewed 602 times since Mon, Sep 28, 2020
XMLHttpRequest.responseURL
Viewed 519 times since Wed, Sep 30, 2020
How to get Response Header location from jQuery Get?
Viewed 752 times since Wed, Sep 30, 2020
How to hide image broken Icon using only CSS/HTML?
Viewed 808 times since Wed, Sep 30, 2020
Get The Current Domain Name With Javascript (Not the path, etc.)
Viewed 587 times since Fri, Oct 2, 2020
Regex in Javascript to remove links
Viewed 530 times since Sat, Oct 3, 2020