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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jquery, ajax, servlet and null data in callback function

 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
isn't that what the fiddler is showing me?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Either. Does the response contain the expected data and headers?
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Happily living in the valley of the dried frogs with a few tiny ads.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic