Bookmark Topic Watch Topic
  • New Topic

jquery, ajax, servlet and null data in callback function

 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am using tomcat and running my application on localhost 8080
I have this javascript/jquery call:



and the servlet is doing (i have taken out any attempt at json and just returning plain text)


I installed fiddler 2 and it says?


in the response window:


all of the alerts in the callback function happen but the one alerting about data is just an empty dialog box.
There are no errors in either the firefox error console or the tomcat window.
Does anyone have any ideas what is going wrong?
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
"text" is not a data type option. You should specify xml, html, script, or json.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
when it used to be "application/json" in the servlet (now commented out) and "json" in the jquery
i got the message "data is null" in the firefox console
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Use Firebug to inspect the request/response to see what's really being returned.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
isn't that what the fiddler is showing me?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Either. Does the response contain the expected data and headers?
 
Filipi Zimermann
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Report post to moderator
Try using the ajax method for better error details.
In your case, instead of jQuery.post() use:


I can bet the problem is the JSON sintax you are using in your servlet response.
Use quotes on the keys... to return something like:
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
interestingly i get exactly the same behaviour when i use this:


it goes into success with a null value for data.
 
Filipi Zimermann
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hmmm... very interesting.

My last shot is trying this at your servlet:


But if you got null at the data parameter and didn't got the error, I'm not really sure if this will work.
Please let me know how you solved it.
 
Wendy Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am testing this using eclipse with debug in the servlet.
I am getting the success response before my breakpoint has been activated.
I went back to the old version



I am getting status code 0. Thank you all for your help. I haven't solved it yet
 
    Bookmark Topic Watch Topic
  • New Topic