Thread: Javascript: Error in FTP access

  1. #1
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    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:[email protected]/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?
    Last edited by alphaoide; 05-09-2005 at 07:19 PM.
    source: compsci textbooks, cboard.cprogramming.com, world wide web, common sense

  2. #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.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

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