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 Answers
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.
3 Comments
Mina
I know the best way is using ajax but I was told to do this without using ajax !!
Ben-G
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.
Ben-G
Just changed the content of my answer, to the content of the comment. You may want to mark it as correct answer.
Try something like this,
var json = xmlHTTPRequest.responseText,
obj = JSON.parse(json);
alert(objJSON.result);
alert(objJSON.count);
1 Comment
Mina
xmlHttpRequest is xhr and ajax ,I don't want to use ajax !