Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

jquery, ajax, servlet and null data in callback function

 
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?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • 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 L 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
 
Marshal
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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 L 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
Marshal
Posts: 67389
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Either. Does the response contain the expected data and headers?
 
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 L 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 L 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
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic