| Author |
Converting JSONArray to JSONString
|
Ashutosh Arya
Ranch Hand
Joined: Oct 07, 2008
Posts: 69
|
|
Hi..
I am sending one JsonArray to JSP and want to convert the same into JSONString..I am trying with toJSONString but it is not working fine...
My code is below
var mypostrequest = new ajaxRequest()
mypostrequest.onreadystatechange=function(){
document.getElementById('srchresult').innerHTML="Loading please wait...";
if (mypostrequest.readyState==4){
document.getElementById('srchresult').innerHTML="";
if (mypostrequest.status==200 || window.location.href.indexOf("http")==-1){
var response = mypostrequest.responseText;
var jsondata=eval(response.toJSONString()); //retrieve result as an JavaScript object
var data=jsondata.items
var output=''
for (var i=0; i<data.length; i++){
alert(data[i]);
output+='<li>'
output+=data[i]
output+='</li>'
}
output+='</ul>'
document.getElementById("srchresult").innerHTML=output
}
if Anybody having any idea please reply...
thanks
Kanav>
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
|
|
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.
For more information, please read this.
This post has been moved to a more appropriate forum.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Did you make this up: response.toJSONString() or is it part of some framework.
Eric
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
Look at my example here: http://www.coderanch.com/t/435631/HTML-JavaScript/JSON-Syntax-error#1936041
Eric
|
 |
 |
|
|
subject: Converting JSONArray to JSONString
|
|
|