Hi,
I had posted to try and get some help with the .get yesterday and I got the info I needed and it seems to work now but my .each loop will only display the first item, so in effect its not looping over my JSON object. This is the code
var startURL = "http://" + top.location.host;
//We tell jquery to load when the doc is ready
var JsonPath = startURL + "<%=UrlPath%>";
$.get(JsonPath, function(data){
//then we take out any double quotes
newString = data.replace(/\"/g,'\'');
// then put back doublequotes
mydata= newString.replace(/\`/g,'\"');
//we remove any line brakes
mydata= mydata.replace(/\n/g,'');
alert(mydata);
data = JSON.parse(mydata);
//Now we loop over our data set
$(function(){
$.each(data.images, function(entryIndex,entry)
{
alert('this is new code');
//document.getElementById('photos').innerHTML = document.write(entry.images.body);
});
});
this is what my JSON looks like
[
{
"images": {
"filetype": "Video",
"vidlink": "http://www.mediacollege.com/video-gallery/testclips/barsandtone.flv",
"limage": "",
"timage": "Tumb.jpg?MOD=AJPERES",
"body": "<span style='font-weight: bold;'>This is test two</span><br><br><a href='http://google.com/' >This is a link</a><br>",
"abstract": "This is a test for the video",
"title": ""
},
"images": {
"filetype": "Video",
"vidlink": "http://video.flv",
"limage": "",
"timage": "test.jpg?MOD=AJPERES",
"body": "<p style='margin: 0px;'>will this work in the json <br></p><p style='margin: 0px;'>file<br></p>",
"abstract": "This is a test for the video",
"title": ""
}
}
]
I have tested the JSON at JSONLint and it comes back fine I just don't understand why it will not loop over the list. Like I said if I only have one item in the list it works just fine but once there are more elements in the JSON file it craps out.
Again thanks for any help I'm still new to JQuery so just trying to find my way around it.
Mike.