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 7414297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:04:44+00:00 2026-05-29T07:04:44+00:00

I have searched on here for some time and can’t find a specific answer

  • 0

I have searched on here for some time and can’t find a specific answer to a simple issue.

I have some generated HTML which includes links to files which may or may not exist on the server. The generator doesn’t know if the files exist or not so it assumes they do.

I’m trying to use the JQ AJAX methods to check for the broken href’s and hide() the link if the file is non-existent, should be simple enough I think.

<tr>
    <td>24</td>
    <td>201106</td>
    <td>PRODID</td>
    <td>ABC</td>
    <td>98</td>
    <td>40.95</td>
    <td>4013.1</td>
    <td>15.56365</td>
    <td>2487.8623</td>
    <td>61.99</td>
</tr>
<tr>
    <td colspan="9" style="border-top:#047D66 solid 1px; background-color:#e0e0e0; border-bottom:#047D66 solid 1px"><br></td>
    <td><a href="http://dashboards/wrappedstuff_uk/files/PRODID.pdf" id="checklnk">PDF</a></td>
</tr>

My Jquery script

$.ajax({
    url: $('#checklnk').attr('href'),
    type: 'text',
    method: 'HEAD',
    error: function() {
        $(this).hide();
    },
    success: function(){
        $(this).css('background-image',url('/dashboards/cms/intra/images/icon-link-pdf.png'));
    }
});

The links are not hidden and I suspect the problem might be that $(this) is not the DOM element I expect.

Anyone like to point me in the right direction.

  • 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-05-29T07:04:45+00:00Added an answer on May 29, 2026 at 7:04 am

    You guessed it right $(this) doesn’t refer to the href, you will need to use element id to do your stuff. Something like this

    $("#checklnk").hide();
    

    OR

    Check all anchor tags on the page in one shot

     $("a").each(function(i){
          $.ajax({
              url: $(this).attr('href'),
              type: 'text',
              method: 'HEAD',
              error: function() {
                    $(this).hide();
              },
              success: function(){
                    $(this).css('background-image',url('/dashboards/cms/intra/images/icon-link-pdf.png'));
              }
          });        
      });
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched a long time and cannot find a solution to my problem.
I have searched and searched and I cannot find a page which spells out
I already searched a long time for a good solution, but I can't find
So, I searched some here, but couldn't find anything good, apologies if my search-fu
I have searched the internet for an answer to what could be causing EXCEPTION_ACCESS_VIOLATION
I have some Zend Framework apps running and it's time to add user access
On my page I have a lot of textpages and to save some time.
I want to know mobile number from android apps.I searched in here.some one give
I have searched and have found almost nothing, so I would really appreciate some
After having searched for an answer thoroughly on SO, I have to ask my

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.