Connecting Tech Pros Worldwide Forums | Help | Site Map

Ajax: Problems with Javascript debugging

Phrank
Guest
 
Posts: n/a
#1: Aug 31 '08
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
Guest
 
Posts: n/a
#2: Aug 31 '08

re: Ajax: Problems with Javascript debugging


Phrank wrote:
Quote:
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
http://JavaScript.FAQTs.com/
Phrank
Guest
 
Posts: n/a
#3: Aug 31 '08

re: Ajax: Problems with Javascript debugging


On Aug 31, 10:21*am, Martin Honnen <mahotr...@yahoo.dewrote:
Quote:
Phrank wrote:
Quote:
The failed script follows an example in Steven Holzner's Ajax Bible pp
379-400. It is located athttp://hackingajax.alimentarus.net/sixth.shtml
>
Quote:
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
XMLHttpRequestObject.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
Quote:
--
>
* * * * Martin Honnen
* * * *http://JavaScript.FAQTs.com/
Martin Honnen
Guest
 
Posts: n/a
#4: Aug 31 '08

re: Ajax: Problems with Javascript debugging


Phrank wrote:
Quote:
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
XMLHttpRequestObject.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 XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

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

if (window.XMLHttpRequestObject) {

and that condition (if (window.XMLHttpRequestObject)) is never true as
XMLHttpRequestObject 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 (XMLHttpRequestObject)

--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread