Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-05-2012, 11:18 AM   PM User | #1
Jimmyborofan
New to the CF scene

 
Join Date: May 2008
Location: Milton Keynes
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Jimmyborofan is an unknown quantity at this point
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?
Jimmyborofan is offline   Reply With Quote
Old 11-06-2012, 06:57 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,882
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
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.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:23 AM.


Advertisement
Log in to turn off these ads.