hi
Trying to parse json from a site and the site doesn't have a lot of help yet for their new api so I'm a bit stuck. The json comes back from the site as follows.
If it's successful:
If it's a fail:Code:{"result":[{"vid":"111111","title":"name","type":"archived","username":"myusername","size":"320x240","created":"1267818519","length":"0","upvotes":"0","preview":"","mirrors":"","views_live":0,"views_total":0,"comment_count":0,"page":"http:\/\/site.com\/v\/111111","deviceClass":"webcam"}]}
At the moment I'm working with the fail as it's simpler so I have the following but my alert does nothing.Code:{"error":"Could not find any matching videos."}
Am I missing something here or is the JSON badly formed as it looks like it's missing outer brackets? If I test on this flickr json (http://api.flickr.com/services/feeds...jsoncallback=?) which has brackets, it works fine.Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> function check() { $.getJSON("sitesjson.json", function(data) { alert(data.error); }); } </script> </head> <body onload="check()"> </body> </html>
Any help much appreciated
Garrett




Bookmarks