473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Test if file exists before displaying with XMLHTTP

I have a left menu that is accessed and displayed via XMLHTTP (it resides on
the same server). Some sections of the web site don't have a "menu.asp", so
a "Page Not Found" page is returned, which doesn't look great in the menu
column.. Is there a way to know if a page exists before using
xml.responseText to pull it?
(apart from checking the actual text of the returned page to see if it
contains error-like words)
Thanks
Giles
(PS using xmlhttp instead of server.execute as the menu-page needs
processing before displaying)
Mar 23 '06 #1
2 1864
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(filespec)) Then
msg = filespec & " exists."
Else
msg = filespec & " doesn't exist."
End If
if you do not know the physical path you can try this

Set pc = Server.CreateObject("MSWC.PermissionChecker")

pc.HasAccess(url)
if you have permissions the file must exist

I have not checked this, but its worth a try


"Giles" <gi***@nospam.com> wrote in message
news:Ok**************@TK2MSFTNGP11.phx.gbl...
I have a left menu that is accessed and displayed via XMLHTTP (it resides
on the same server). Some sections of the web site don't have a "menu.asp",
so a "Page Not Found" page is returned, which doesn't look great in the
menu column.. Is there a way to know if a page exists before using
xml.responseText to pull it?
(apart from checking the actual text of the returned page to see if it
contains error-like words)
Thanks
Giles
(PS using xmlhttp instead of server.execute as the menu-page needs
processing before displaying)

Mar 23 '06 #2

"Giles" <gi***@nospam.com> wrote in message
news:Ok**************@TK2MSFTNGP11.phx.gbl...
I have a left menu that is accessed and displayed via XMLHTTP (it resides on the same server). Some sections of the web site don't have a "menu.asp", so a "Page Not Found" page is returned, which doesn't look great in the menu
column.. Is there a way to know if a page exists before using
xml.responseText to pull it?
(apart from checking the actual text of the returned page to see if it
contains error-like words)
Thanks
Giles
(PS using xmlhttp instead of server.execute as the menu-page needs
processing before displaying)


Just test the XMLHTTP.Status property after attempting to fetch it. If it's
404 the file didn't exist and the responseText will contain the sites 404
content.

Anthony
Mar 23 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jennifer Smith | last post by:
Currently we have a site that allows users to listen to mp3 files. It is creating bandwidth issues. So we want to move the mp3 files to an ISP that caps bandwidth usage. Ours is currently...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
22
by: petermichaux | last post by:
Hi, I'm curious about server load and download time if I use one big javascript file or break it into several smaller ones. Which is better? (Please think of this as the first time the scripts...
5
by: hatsumoto | last post by:
Hello, I create an ActiveXObject("Msxml2.XMLHTTP") from my HTML page to submit (i.e. post) XML to a server. I can see the content of the XML response via javascript alert(xmlhttp.responseText)....
5
by: chadschultz | last post by:
Hi there! A friend of mine asked about how to have a line of HTML be written based on whether or not a certain file exists in the server. So if the file is there, a line of HTML is printed; if the...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
0
by: wasif | last post by:
I am trying to upload file using ajax and php but having some problems. it always says that there was a problem and file is not uploaded. here is the code form and ajax code <!DOCTYPE html...
2
by: Jaweed Sheikh | last post by:
Actually iam consuming a web service from traditional ASP and trying to read the XML from Javascript. Will appriciate any quick help. Here is the code <% If...
19
by: RossGK | last post by:
I'm a bit new to javascript - as will be obvious below. I'm using an XMLHttpRequest to get a bit of data from server (django), and it works nicely for single events. But my eventual outcome...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.