[jQuery] $.getJSON isn't working while getting the JSON data from hidden field
Hi,
I amn't able to parse hidden form field data in $.getJSON method,
seems like I am missing something.
Hidde Field:
<input id="videoListJson" type="hidden" value="{
'array':[
{
'title' :'title of video',
'description' :'this is a movie clip',
'postedBy' :'null',
'thumbnailData' :'null',
'noOfViews' :'2345',
'noOfComments' : '123',
'rating' :'4',
'thumbnailUrl' :'assets/dynamic/test_video.jpg',
'variantId' :'1',
'localeId' :'0',
'feedTypeID' :'0',
'feedId' :'12',
'videoId' :'null',
'feedUploadedDate' :'null'
},
{
'title' :'title of video',
'description' :'this is a movie clip',
'postedBy' :'null',
'thumbnailData' :'null'
}]
}" />
This is my hidden filed with JSON value which I access in jQuery code,
I ma just storing in a variable videoListJson and getting in the
string format.
Pass the videoListJson into $.getJSON method a data parameter but it
didn't execute, seems like due to invalid data format or $.getJSON is
breaking somewhere.
jQuery Function:
$(function(){
var videoListJson = $('#videoListJson').val();
alert($('#videoListJson').val());
$.getJSON(videoListJson,
//function(data){
$.each(storeJson, function(i,item){
for(k=0; k < item.length; k++) {
$(".itemContainer")[k].innerHTML = '<div
class="imageContainer"><a href="#" class="balloonTarget"
balloonStyle="whiteBalloon"><div class="ballonInfo hidden">this is the
info</div><img src=" '+item[k].thumbnailUrl+'" /></a></div><div
class="title">title of video</div>';
}
});
});
})
I am able to work by just doing cutom JavaScript:
var storeJson = eval('(' + $("#videoListJson").val() + ')');
But it losses the purpose of $.getJSON which works the same way.
Any pointers should be appreciated.
Thanks
Mohammed Arif