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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:57:02+00:00 2026-05-25T22:57:02+00:00

I was trying to make hidden div which shows on when .txt file is

  • 0

I was trying to make hidden div which shows on when .txt file is found.
I want the div to show the content of the .txt file.

Is that possible?

I have tried to make it by using jQuery but without success.

Idea is simple: div box with constant dimensions which shows content of .txt file which is in same folder on server, but when there isn’t any .txt file div becomes hidden (for example in jQuery $("p").hide();).

  • 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-25T22:57:03+00:00Added an answer on May 25, 2026 at 10:57 pm

    This depends on the usage, but say you have your div for the text, you can make that invisible by setting it to display:none in css.
    Now you can either try getting the file with an ajax call, or you can use a ajax head call to check if the file exists on the server.
    Just getting the file is faster if it exists, as a head call only checks if it’s there, and another ajax call would be neccessary to get the content of the file, however a head call is faster it it does not exist as it does’nt get the content of the file.

    EDIT: but since the file does not exists, there is nothing to get, so a head call is probably not needed here as a “get” would be faster in both situations, but the example still shows how to check if a file exists on the server, and then do something if it does or does not exist.

    It would look like something like this.

    $.ajax({
        url:'http://www.mysite.com/myfile.txt',
        type:'HEAD',
        error: function()
        {
            //file does not exists, no need to do anything
        },
        success: function()
        {
            //file exists get the file and put in the textcontainer and make that visible
            $.ajax({
               url:'http://www.mysite.com/myfile.txt',
               success: function(data)
                  {
                     $("#textcontainer").show().text(data);
                  }
    
        }
     });
    

    Or the other way around with the textcontainer visible with display:block etc :

    $.ajax({
        url:'http://www.mysite.com/myfile.txt',
        type:'GET',
        error: function()
        {
            //file does not exists, hide the textcontainer
            $("#textcontainer").hide();
        },
        success: function(data)
        {
            //file exists get the file and put in the textcontainer that is already visible
             $("#textcontainer").text(data);
        }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a div which expands to show hidden content when
I have a div that I am trying to make hidden by default, and
I'm trying to make some decoration outside the main content div, that would be
I'm just trying to make a list of questions with hidden answers that shows
I am trying to make a directory which contains information in a div, some
I'm trying to make a sidebar which on a website which will have a
I have a site that I'm trying to make a printable version and I'm
I am trying to make an image hidden hidden using jQuery. I am using
I'm trying to make parts of a list hidden when the page loads. Specifically
Hi I'm trying to make the first element of my observableArray hidden, the following

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.