Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7922593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:01:02+00:00 2026-06-03T17:01:02+00:00

All I want to do with my ajax code is check the HTML status

  • 0

All I want to do with my ajax code is check the HTML status code that is returned by the request (searching for 404s with links). I’ve written the following code:

$.ajax({
    url: link,
    statusCode: {
        404: function() {
            alert("Not found");
        },
        200: function() {
            alert("Found!");
        }
    }
});

where “link” is a link to an image url on another site. I know that because of the same origin policy I can’t really make requests to other sites, but is there some exception for doing this if all I want to check is a return status?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T17:01:02+00:00Added an answer on June 3, 2026 at 5:01 pm

    When you’re trying to do stuff you’re not supposed to, one strategy I like to use is to find somewhere where it already works for the browser, then trick that into working for me. In terms of downloading images cross-domain, the browser already implements this functionality in the <img> tag.

    Image tags support a DOM event loaded which you could use to trap if the image was loaded successfully.

    The downside is that you won’t always know if the image being returned is the actual image or if it’s a redirect image because the server is configured to now allow hot linking of images. You also have no indication of if the request failed or not.

    The latter downside can be overcome by a timer which, while not as robust as you’d probably like, might still work depending on your application.

    Here’s some sample (ie. untested) code I whipped up to give you an idea…

    function isImagePathValid(src, callback) {
       // Setup a timer to catch if it never loads
       var fallback = setTimeout(function() {
           callback(false);
       }, 5000);  // Wait 5 seconds
    
       // Create a temp <img> tag and wait for it to load
       $('<img style="position:absolute; top:-9999; left:-9999;" src="' + src + '" />')
          .appendTo('body')
          .load(function() {
              clearTimeout(fallback);
              callback(true);
          });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have all ajax requests check the HTTP response code, is it
all I want to show hide some ids using jQuery. My html code is
To dynamically fill DropDown controls on my HTML Form, I have written code that
I'm trying to intercept all AJAX calls in order to check if that AJAX
I have the following code. I want to add/remove check-box values to an array
All I want to do is to check if the textfield has been changed.
All i want is to pass a HTML (DOM object) from javascript to Actionscript.
All I want is to clear my renderTarget2D once so that it starts off
right i have a form, it uses ajax to check the if all fields
This is my code: <html> <head> <script src=https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js></script> <script> $(document).ready(function() { $('.chk').live('change', function() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.