wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Prototype Ajax.Request error - Function Expected Options Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Prototype Ajax.Request error - Function Expected Options " Watch "Prototype Ajax.Request error - Function Expected Options " New topic
Author

Prototype Ajax.Request error - Function Expected Options

Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
I'm getting the above error and i'm not sure why.
Here is the code i'm calling. This is in a custom js file that is
attached after the prototype library.

the 1st alert runs fine, but then i get that error. Any ideas? This
AddVenueToFavorites is a servlet.
[ May 01, 2008: Message edited by: Ilya Elkind ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Hmm, I don't see anything awry on first inspection. Are you getting this error before the request fires or after the response returns? Are you using Firebug in Firefox to debug? It's essential for debugging Ajax requests.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
I'm not using FF.

This is happening before the servlet is called. I first get the initial alert saying its about to do the ajax but it never gets to the servlet. I know this because i have a sysout statement as the first line of code in the doGet method that doesnt get displayed.

Therefore my thought is as follows and please correct me if i'm mistaken. I'm using a few 3rd party scripts. Is it possible that another script has a Ajax wrapper defined?



my code is in custom.js
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
adding to my train of thought, is it possible to call a function of a script from another script? I wouldnt see why not, but who knows.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Originally posted by Ilya Elkind:
I'm not using FF.
Start. Regardless of whether Firefox support is on your radar or not, Firebug in Firefox is by far the best way to find out what is going on with your Ajax requests. FF also has other great plugins like TamperData.

Trying to debug Javascript in IE is like trying to cut diamonds wearing welder's gloves.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Originally posted by Ilya Elkind:
adding to my train of thought, is it possible to call a function of a script from another script? I wouldnt see why not, but who knows.


Yes. They are all loaded into the same context. Caveat: you can call anything inline until it has been defined.
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
Ok i took your advice and it worked like a charm. I dl'd FF and installed Tamper Data plugin. Found out the call to my servlet was the wrong path.
It was trying to call localhost:8080/AddVenueToFavorites.

Once i added my domain, then it worked.

I changed the line
new Ajax.Request('/AddVenueToFavorites',...
to
new Ajax.Request('/MYDOMAIN/AddVenueToFavorites',...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

These tools are the bomb, aren't they?
[ May 02, 2008: Message edited by: Bear Bibeault ]
Joshua Elkino
Ranch Hand

Joined: Jul 24, 2007
Posts: 91
Quite amazing.

I was actually holding off FF testing till i was ready for that phase but this will help for debugging.

Hope IE8 will have something equivilent.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Originally posted by Ilya Elkind:
Once i added my domain, then it worked.
Just a terminology correction in case it causes future confusion, that's not your "domain", it's the context path of the web application.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60792
    
  65

Originally posted by Ilya Elkind:
I was actually holding off FF testing till i was ready for that phase but this will help for debugging.
I find it's best to simultaneously develop for all browsers, relying on Firefox for the brunt of debugging of all but browser-specific issues.

Hope IE8 will have something equivilent.
My jQuery in Action co-author is very excited about the prospects of IE8, but I've been so disappointed with IE7 that I'm setting my expectations very low.
[ May 02, 2008: Message edited by: Bear Bibeault ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Prototype Ajax.Request error - Function Expected Options
 
Similar Threads
help with Prototype
why javascript can't redirect under Struts
Ajax : how to replace another option list?
My AJAX Chained Selector Function (Enjoy!)
retrieve JSON from servlet