P
P
Partizanin2016-01-22 20:54:34
JavaScript
Partizanin, 2016-01-22 20:54:34

Java Servlet Json having trouble accepting a json object in a web page?

Tell me what could be the trouble, in one web project it normally sends and receives json objects, but not in the other!

there is a srevlet in which the response java object is sent to the web page, the object of the org.json library is nested in the json object on the page, the object is received and the parameters are taken from the js object.

Working servlet pastebin.com/jkkUXa0q

This is how I accept the response from the server on the web page pastebin.com/W6SqjM87

Everything is similar here, but on the page the object is accepted as a string and not as a js object, that is, you can’t get parameters from it
pastebin.com/9X0iLhUM
pastebin.com /1quekm4R

This is what happens, the page receives a list not with objects from which you can get the value by keys, but a list with strings
FzZAYg5.png?1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2016-01-22
@bromzh

response.setContentType("text/plain; charset=utf-8");

And should be "application/json"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question