Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: testing for 404

  1. #1
    New to the CF scene
    Join Date
    May 2008
    Milton Keynes
    Thanked 0 Times in 0 Posts

    testing for 404

    Could I do this using Ajax? I am not really much of a client side developer and I am in a position where I have to learn some bits.

    I am developing a help system where when a button is clicked a light box opens up an external help file

    (it has to be external due to the server architecture and layout, please I have gone into this enough...)

    Anyway the gist is this, if I perform a request and the page is not found I want a 'page not ready' page to be displayed instead, and the best way i can find round this is if the page returns a 404. So if I get this 404 I can call the default page instead.

    I really am not looking for code examples (yet!) as I want to be able to try this out myself. But I need to know is it is possible that on a page button click can I discover if the page requested actually exists or not?

  2. #2
    Master Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Behind the Wall
    Thanked 567 Times in 560 Posts
    yes, you can do that with AJAX. there are 2 principal ways to do it:

    - only check for the file: make a HEAD request (like GET, only it asks for headers). check if the status property is 404.

    - make a regular file request. check if the status property is 404.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts