aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jquery, ajax, servlet and null data in callback function Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply locked New topic
Author

jquery, ajax, servlet and null data in callback function

Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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

Joined: Jul 11, 2001
Posts: 15299
    
    6

"text" is not a data type option. You should specify xml, html, script, or json.


GenRocket - Experts at Building Test Data
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

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

Joined: Jan 10, 2002
Posts: 61433
    
  67

Use Firebug to inspect the request/response to see what's really being returned.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

isn't that what the fiddler is showing me?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Either. Does the response contain the expected data and headers?
Filipi Zimermann
Greenhorn

Joined: Mar 26, 2008
Posts: 21
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

Joined: Oct 21, 2008
Posts: 1107

interestingly i get exactly the same behaviour when i use this:


it goes into success with a null value for data.
Filipi Zimermann
Greenhorn

Joined: Mar 26, 2008
Posts: 21
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

Joined: Oct 21, 2008
Posts: 1107

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jquery, ajax, servlet and null data in callback function