JSON parsing with Javascript and jQuery -
bfunc({ "query": { "count": 1, "created": "2013-05-03t06:20:01z", "lang": "en-us", "diagnostics": { "publiclycallable": "true", "cache": { "execution-start-time": "32", "execution-stop-time": "32", "execution-time": "0", "method": "get", "type": "memcached", "content": "http://www.vtualerts.com/robots.txt" }); this json data need parse using javascript , jquery. tried this......
<div id="placeholder"></div> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script> $.getjson('myjson.json', function(data) { var output= data.cbfunc.query.count+ "" + data.cbfunc.query.created; document.getelementbyid("placeholder").innerhtml=output; }); but getting error
xmlhttprequest cannot load file:///home/shivratna/desktop/myjson.json. origin null not allowed access-control-allow-origin.
please help.
sincere thanks
it's not valid json. read @ json.org proper structure json. have there jsonp. before else, check json, don't close properly. lack closing braces.
to turn valid json, remove padding function so:
{ "query": { "count": 1, "created": "2013-05-03t06:20:01z", "lang": "en-us", "diagnostics": { "publiclycallable": "true", "cache": { "execution-start-time": "32", "execution-stop-time": "32", "execution-time": "0", "method": "get", "type": "memcached", "content": "http://www.vtualerts.com/robots.txt" } } } }
Comments
Post a Comment