Test if file exists before displaying with XMLHTTP

G

Giles

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)
 
S

Slim

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
 
A

Anthony Jones

Giles said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,087
Members
48,773
Latest member
Kaybee

Latest Threads

Top