C Board  

Go Back   C Board > Community Boards > Tech Board

Reply
 
LinkBack Thread Tools Display Modes
Old 05-09-2005, 05:56 PM   #1
unleashed
 
alphaoide's Avatar
 
Join Date: Sep 2003
Posts: 693
Javascript: Error in FTP access

The following is a routine to download content of a file.
Code:
var req = new XMLHttpRequest();
req.open( 'GET', 'ftp://username:password@mysite.com/index.html', true );

req.onreadystatechange = function() {
  if( req.readyState == 4 ) {
    print( req.responseText );
  }
}
req.send( null );
It works fine except for the error handling. When login info is incorrect the following generic javascript window pops up.
Code:
530 Login Incorrect
When the file does not exits, it will pop up the following.
Code:
550/index.html No such file or directory
What I want to do is to suppress the generic error window and its message with my own. So how do I capture the type of error (error 530, 550, etc), and how do I prevent the generic javascript erro window from popping up?
__________________
source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

Last edited by alphaoide; 05-09-2005 at 07:19 PM.
alphaoide is offline   Reply With Quote
Old 05-10-2005, 07:07 AM   #2
5|-|1+|-|34|)
 
ober's Avatar
 
Join Date: Aug 2001
Posts: 4,429
You'd probably be better off asking this in a web developer community.

EDIT: But AFAIK, there is no error trapping in JS.
ober is offline   Reply With Quote
Old 05-10-2005, 07:13 AM   #3
Cat without Hat
 
CornedBee's Avatar
 
Join Date: Apr 2003
Posts: 8,492
Yes, there is. Since 1.4, I think, JavaScript supports try ... catch.

But it won't work in this situation, because that FTP handling is done internally.

I won't even talk about the absurdity of using XMLHttpRequest to get a file that is neither XML nor retrieved over HTTP.
__________________
All the buzzt!
CornedBee

"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
CornedBee is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript book recommendations neandrake Tech Board 2 04-05-2009 12:27 PM
Whats FTP Stan100 Tech Board 13 01-22-2004 05:10 PM
Visual Studio and FTP Server... Grayson_Peddie Networking/Device Communication 0 09-03-2003 12:31 PM
FTP Server :: Winsock kuphryn Windows Programming 2 10-03-2002 07:14 PM


All times are GMT -6. The time now is 07:35 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22