Ajax: Problems with Javascript debugging

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phrank

    Ajax: Problems with Javascript debugging

    Hello

    I am teaching myself AJAX, and have now gotten to the point where
    syntax errors are removed. I am using Javascript and HTML for now, to
    get a dropdown menu.

    The failed script follows an example in Steven Holzner's Ajax Bible pp
    379-400. It is located at http://hackingajax.alimentarus.net/sixth.shtml

    I have tried ddd, greasemonkey, and a number of other debuggers,
    including firefox's own error console, under Linux. All of them have
    seem to have this same screwball way of numbering the lines.
    Apparently the error is being reported on line 344 on a file which has
    only 150 or so lines.

    When seen under Explorer, the page is completely blank.

    If anyone can shed light on this issue, I would be grateful.

    Paul King
  • Martin Honnen

    #2
    Re: Ajax: Problems with Javascript debugging

    Phrank wrote:
    The failed script follows an example in Steven Holzner's Ajax Bible pp
    379-400. It is located at http://hackingajax.alimentarus.net/sixth.shtml
    >
    I have tried ddd, greasemonkey, and a number of other debuggers,
    including firefox's own error console, under Linux. All of them have
    seem to have this same screwball way of numbering the lines.
    Apparently the error is being reported on line 344 on a file which has
    only 150 or so lines.
    Take the line
    var e=new MouseEvent(evt) ;
    out and simply use the evt object you already have.

    --

    Martin Honnen

    Comment

    • Phrank

      #3
      Re: Ajax: Problems with Javascript debugging

      On Aug 31, 10:21 am, Martin Honnen <mahotr...@yaho o.dewrote:
      Phrank wrote:
      The failed script follows an example in Steven Holzner's Ajax Bible pp
      379-400. It is located athttp://hackingajax.ali mentarus.net/sixth.shtml
      >
      I have tried ddd, greasemonkey, and a number of other debuggers,
      including firefox's own error console, under Linux. All of them have
      seem to have this same screwball way of numbering the lines.
      Apparently the error is being reported on line 344 on a file which has
      only 150 or so lines.
      >
      Take the line
         var e=new MouseEvent(evt) ;
      out and simply use the evt object you already have.
      >
      Thanks, that appears to get rid of the worst of the errors. In fact
      now there are none listed, but still I have no dropdown menu. It is
      supposed to read a file through a call to
      XMLHttpRequestO bject.open("GET ", dataSource)
      and it doesn't appear as though the file is being read. The file,
      "items1.txt ", is a simple CSV of what the list items are. The file is
      certainly readable when I point my browser to it, because the file
      contents are displayed.

      Once again, the call seems to be correctly written, and dataSource's
      value is set through an implicit "if":

      var dataSource = (menu == 1) ? "items1.txt " : "items2.txt ";

      Paul King
      --
      >
              Martin Honnen
             http://JavaScript.FAQTs.com/

      Comment

      • Martin Honnen

        #4
        Re: Ajax: Problems with Javascript debugging

        Phrank wrote:
        Thanks, that appears to get rid of the worst of the errors. In fact
        now there are none listed, but still I have no dropdown menu. It is
        supposed to read a file through a call to
        XMLHttpRequestO bject.open("GET ", dataSource)
        and it doesn't appear as though the file is being read.
        You have that open call inside an if block

        function getData (menu) {
        var XMLHttpRequestO bject = false;

        if (window.XMLHttp Request) {
        XMLHttpRequestO bject = new XMLHttpRequest( );
        } else if (window.ActiveX Object) {
        XMLHttpRequestO bject = new ActiveXObject(" Microsoft.XMLHT TP");
        }

        var dataSource = (menu == 1) ? "items1.txt " : "items2.txt ";

        if (window.XMLHttp RequestObject) {

        and that condition (if (window.XMLHttp RequestObject)) is never true as
        XMLHttpRequestO bject is a local variable of the getData function and not
        a property of the window object. So get rid of that if check or change it to
        if (XMLHttpRequest Object)

        --

        Martin Honnen

        Comment

        Working...