Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All


Can you please tell me how to check wheather file exists on server using javascript
Posted

JavaScript is a client side technology and would know nothing about what's there on the server until you do a postback.
There is a technology called AJAX which does exactly what you require. Quoting AJAX definition from Wikipedia[^]:
AJAX an acronym for Asynchronous JavaScript and XML is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data is usually retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not needed (JSON is often used instead), and the requests do not need to be asynchronous.


There are many examples for the same on the web. Search Google for "AJAX asp.net" or "jQuery AJAX" (post using jQuery is what lot of people are using these days) to get started.

Hope this helps!
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 9-Apr-12 13:32pm    
Right, a 5.
--SA
Ankur\m/ 10-Apr-12 0:44am    
Thank you, SA!
VJ Reddy 10-Apr-12 4:31am    
Well explained. +5
Building off of Ankur's answer, you can find a good example here
 
Share this answer
 
Agree with Ankur and PopeDarren.
AJAX is the best option for checking file existance.
Use Page.Methods() function in JAVA Script to check existance of file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900