By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,817 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,817 IT Pros & Developers. It's quick & easy.

Ajax test before data request

P: 7
Hi everyone.

I am finally starting to focus more time on learning AJAX for the last few days, and I ran into a problem I couldn't find a solution too, or find much info on how to do this.

What I am looking to do is have a page that is displaying content (varies between docs to videos) which are all pulled up from within a web browser (always IE).

What currently happens is every few minutes the data is refreshed (iframe refresh though javascript) and new content is displayed. The problem I am running into is sometimes if the internet connection goes down (on the client side) and the refresh happens you will get a page cannot be displayed and no attempt can be made again to request data.

What I am looking to do (or at least find more details about) is instead of the refresh have an AJAX script that first checks if it can make the connection to the database. If not an error is displayed instead of the content and it trys again in 30 seconds. Otherwise the data from the database is requested and everything works fine and the data will be requested as normal.

I would think this is something you could do with AJAX but I have not been able to find any details on where to start. Can anyone help me out?
Jul 11 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
You could make a HEAD request for the URL instead of a GET request. If the status is 404 or some other error state, display an error message.
Jul 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.