Saturday, August 1, 2009

[jQuery] Evaluating json problem

Hello,

I'm trying to execute simple scenario, from the server side (servlet)
I'm returning: out.print("[{\"type\":\"basic\"}]");

on the client side I have :

var dataURL = "<%=response.encodeURL(request.getContextPath())%>/
FetchData";

var items1;

$.getJSON(dataURL, function(json){

eval("items1="+json);
});

FireFox is showing jscript exception in the console:

Error: missing ] after element list
Source File: http://localhost:10038/wps/PA_1lb791mt//jsp/html/test.jsp
Line: 345, Column: 15
Source Code:
items1=[object Object]


Also tried with, but result was the same :
items1 = eval("(" + eval(json) + ")");

Lost several hours trying to solve this but no success.

Thanks

No comments: