Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javascript "object expected " error

 
albert sie
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i run my jsp page, the error "object expected" come out in my prototype program. here i stick on the code for the expert here to give some opinion to me.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64688
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the HTML/Javascript forum.
 
Stefan Evans
Bartender
Posts: 1688
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Object expected" is pretty much equivalent to "Null pointer exception" in java.
Something is null.

There is way too much code there to give any reasonable answer.
If you could get a line number, or approximate region from where the error is coming, post that segment of code, but this is too much. Particularly with scriptlet code mixed in as well.

You do realise that java and javascript don't mix?
ie the java is executed, and produces HTML which is sent to the page.
The java code is NOT executed on as part of calling the javascript function "ret_data"

Tips for debugging javascript.
- View source on the generated page. Save it as HTML. Fiddle with the HTML until the javascript is fixed, and then apply those fixes to the JSP.
- I recommend putting alert('Here we are'); at appropriate places through the script to see at which point it stops running. That helps to pinpoint the error.
- you can type in the address bar of the browser stuff like "javascript:alert(document.forms[0].myField)" This gives you a dynamic evaluator.
- Mozilla/Firefox has an excellent inbuilt javascript debugger.
 
Linda Walters
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I debug web applications on a daily basis in my work, including Java servlets, HTML, JavaScript, CSS, XSL, yada, yada, yada, the whole alphabet soup. The best recommendation that I can make is to get one of the Mozilla family of browsers (Mozilla, Firefox or SeaMonkey). My personal preference is Firefox. Once you have it installed, click on Tools|Extensions and click on "Get More Extensions" in the lower right corner. On the Extensions page select "Developer Tools" from the menu and Search for "JavaScript Debugger" this should take you to the page for verions 0.90.87 of the debugger. Follow the installation instructions.

I don't remember off hand if the JavaScript Console and DOM Inspector are currently built into Firefox. If they are, they will be under the Tools menu on Firefox's menu bar. If not, then search for them on the extensions page.

The JavaScript Console is VERY helpful if you don't know where the bug is occurring. As long as it is throwing a JavaScript error it will be caught by the console. When it is, just double click on the line in the console and it will take you right to the offending line in the JavaScript file.

This is a really great suite of tools and I use it every single day.
(No, I do not work for Mozilla)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic