Forum Moderators: open

Message Too Old, No Replies

Weird Ajax-related Javascript error

         

ixos

6:18 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



I'm working on a multiple selection box setup where my users in my company's sales department can narrow products down in the following manner:

1) select category(ies) to look in
2) select manufacturer(s)
3) select vehicle make(s)
4) select vehicle model(s)

As they go through the process, there is a large select box at the bottom that allows them to select products.

My problem exists after the user selects the manufacturer. The manufacturer select box has an onChange that calls post_manufacturer_update() that calls the remote script to get the data for the vehicle make box.

For some reason, it works fine if I put an alert() call before I actually initiate the XMLHttpRequest.open() and XMLHttpRequest.setRequestHeader() calls. With the alert() box, it works fine. Without, I get the following error:

Error: uncaught exception: [Exception... "Component returned failure code: 0x804b000f [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x804b000f (<unknown>)" location: "JS frame :: [emp.kneedraggers.com...] :: populate_bike_makes :: line 173" data: no]

This error only seems to exist within firefox. IE tolerates the code as-is.

The code for populate_bike_makes() is:


function populate_bike_makes(manufacturers, categories){
//alert(manufacturers.length);
//alert(categories.length);
//alert(http.readyState);
alert('Getting Bike Info');
//http.abort();
if((manufacturers.length >= 0) ¦¦ (categories.length >= 0)){
manustring = make_select_string(manufacturers,'manufacturers');
categorystring = make_select_string(categories,'categories');
if((manustring.length > 0) && (categorystring.length > 0)){
http.open('POST','ajax_intl_backend.php',true);
http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http.send("action=get_matching_makes" + manustring + categorystring);
http.onreadystatechange = populate_bike_makes_action;
return true;
}
}
return false;
}

Does anyone know if this has been documented anywhere, or know how I can get around it? I'd really prefer not to have the user click a box everytime they update a manufacturer.

Thanks,
ixos

ixos

6:31 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



Well, it seems that I may have spoken too soon.

After fighting with this thing on and off for a couple days, I took a different look at the situation, and came at it from the back-end.

It seems my problem came from having an extra newline on the data being returned and it seems to have thrown some things off.

Sorry to take up board space with this, but I had given up when I posted! The only information I found on the error I gave above was on some japanese site that had no useful information. Hopefully this helps someone else in the future.

-ixos