Ajax: Problems with Javascript debugging

P

Phrank

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
 
M

Martin Honnen

Phrank said:
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.
 
P

Phrank

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
 
M

Martin Honnen

Phrank said:
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top