My jsp code is
<% List selected = (List) session.getAttribute("clist");
JSONArray arr = new JSONArray();
JSONObject tmp;
for (int i = 0; i < selected.size(); i++) {
tmp = new JSONObject();
tmp.put("Id", selected.get(i));
arr.put(tmp);
}%>
and i am using hidden field to pass this array to javascript
<input type='hidden' id="agencycontactid" name="agencycontactid" value="<%=(null != arr) ? arr : ""%>" />
here arr gives value arr=[{"Id":"9"},{"Id":"11"}]
My javascript code is
var s=$('#agencycontactid').val(); alert(s);
But alert gives only [{
Please help me
Thanks
<input ... value="[{"Id":...>
so the value attribute is only[{
due to the"
in the string you're trying to pass – icke Nov 7 '14 at 9:15