0

I wrote a jsp which request to the servlet and return a json to my jsp ,my problem is that I want to iterate on json and show it in my page ,but I do not know how to get my json in my javascript function . I do not want to use jquery ui an ajax . I want to write it in pure javascript and jsp . tnx for ur help.

2

2 Answers 2

0

Assuming you are already holding the JSON somewhere within your JSP, this examples shows how to access JSP content from a javascript function: JSP/JavaScript-Example. If my assumption is wrong, you maybe want to post your code for further suggestions.

Sign up to request clarification or add additional context in comments.

3 Comments

I know the best way is using ajax but I was told to do this without using ajax !!
Assuming you are already holding the JSON somewhere within your JSP, this examples shows how to access JSP content from a javascript function: JSP/JavaScript-Example. If my assumption is wrong, you maybe want to post your code for further suggestions.
Just changed the content of my answer, to the content of the comment. You may want to mark it as correct answer.
0

Try something like this,

var json = xmlHTTPRequest.responseText,
obj = JSON.parse(json);
alert(objJSON.result);
alert(objJSON.count);

1 Comment

xmlHttpRequest is xhr and ajax ,I don't want to use ajax !

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.