i'm using following jquery code json file couchdb.
function geturl() { var api_url = 'http://127.0.0.1:5984/couchcontentqueue/_design/doccollections/_view/view_all_by_url_name?key="favorite-flickr-photos"&?callback=?'; $.getjson(api_url, function(json) { var type = json.type; var desc = json.description; $("#dropbox h3").html(type); $("#dropbox p").html(desc); }); };
when on url provides following:
{"total_rows":6,"offset":5,"rows":[ {"id":"f5ba37e5af406ab079d596f7a1f30a2d","key":.... ]}
firebug gives me following error: invalid label http://127.0.0.1:5984/couchcontentqueue/_design/doccollections/_view/view_all_by_url_name?key=%22favorite-flickr-photos%22&?callback=jsonp1304111285023 line 1
i can't figure out how past first line actual json object. ideas? thanks.
?callback=
it looks trying jsonp request, but:
{"total_rows":6, ...
is plain json response , not jsonp call. if don't mean cross-domain jsonp request, rid of callback
parameter , have jquery parse response normal json.
if do need cross-domain jsonp requests, , understand security risks of that, make sure you're using up-to-date couchdb version , add directive:
allow_jsonp = true
to .ini file in [http]
section.
invalid label
is when try execute/eval
string containing json object. quirk of js parsing "x"
in {"x": "foo"}
taken javascript ‘label’ (used continue
statements) in statement block, rather object property name in object literal expression.
jquery use script execution instead of json parsing when thinks doing jsonp request. having ‘callback=’ parameter in url magically makes think that.
Comments
Post a Comment