I never got an answer to my other post on similar problem.....
now trying another example.. basically am trying to make an ajax request with JSON/JSP, not succeeding... now found another example here:
which I'm trying to run here:
but the "something went wrong" code is triggered...
<%@page contentType="text/html; charset=UTF-8"%>
JSONObject obj = new JSONObject();
what is the problem, please..
(not sure if this a JSP or an AJAX problem, sorry for posting here if it's an ajax problem..)
I wouldn't try to do the type of work you're doing in a JSP. Consider using a servlet or action or controller (depending on the web framework you're using).
Btw, I don't see any reason for the code above not to work, but you most likely shouldn't be calling flush yourself. I'm fairly certain that the JSP will try to flush the content it self when it is done.
really? hmmm... was just trying to make example here,
work, which as you can see, has a JSP...
I do know servlets, but they are a pain b/c every time I compile a servlet I have to restart the server (tomcat 5.5) this is a huge pain, and not practical at all when you're just doing a learning exercise... (or in any other situation..)
so why do you say I should do this in a servlet and not a JSP?
Btw, I don't see any reason for the code above not to work, but you most likely shouldn't be calling flush yourself. I'm fairly certain that the JSP will try to flush the content it self when it is done.[/QUOTE]
hmmm... this is how orig example is..
(I took out 'out.flush' line.. but still get same result..)
this is frustrating.. the two JSON/JSP examples I have found online I can't make work (this one http://www.learn-ajax-tutorial.com/Json.cfm#h1.2 also doesn't work.. get errors as described in this thread:
(it's like it's missing json.jar, but it's there...)
Do you get a stacktrace? The "Something went wrong" isn't very helpful...
It looks like the JSPAndAJAXExamples page has its own jar that needs to be in your WEB-INF/lib directory. It looks like the name is json_simple-1.1.jar. Which is different then the json.jar.