I'm trying to get data back from a servlet in JSON format. I am using jquery, and have written a simple test just to return some data and then alert me of it in an html page. However, everytime i reload the page, the value of the data passed back from the servlet is null. If i access the servlet directly, i can see the data posted to the screen.
in text - which is i believe what i want. I've used cactus on the servlet as a test, and it returns the json data, but is it formatted correctly? Am i somehow now sending it back in good format for jQuery? Your ideas are welcomed.
Same result, json is null according to firebugs. It never even gets into the function(json). After .getJSON returns and presumably has called the servlet, and its about to call function(json), json is null and the next step is out of the execution.
I do get 1 error in the error console,
window.console is undefined
http://localhost:8080/test Line 47.. of which there is none. I'm not sure this has any bearing on the problem though.
Okay, yup, i was getting a 404 error because i referring to /TestServlet, instead of /app/TestServlet. That's why i'm a greenhorn! Thanks for your help. One other question. If i'm accessing a potentially large dataset in the servlet that is in a mysql database, is JSON the preferred method or is it XML? I just wanted to gauge your thoughts on the matter.
On the other hand, for something as complex as that, I'd format the result in a JSP and send the resulting HTML fragment back as the result to plunk into the DOM rather than having to parse data and build the DOM in script.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com