I have an json which stored as toc.js for eg the json is like this
[{ "id":"205","name":"apple", "description":"fruit"},
{"id":"206","name":"radio","description":"Electronics"},]
and i am using $.getJSON( url,callback)
in my code.
but the result is in object format, i get t开发者_JAVA百科he output in array format so it can be used in the flash.
I'm trying to grab data from a JSON on an flash but the flash doesn't support JSON-P output.
var foo = '[{ "id":"205","name":"apple", "description":"fruit",}, {"id":"206","name":"radio","description":"Electronics"}]'
foo = JSON.parse(foo);
Object.prototype.toString.call(foo) === '[object Array]'
$.getJSON
will call just that (JSON.parse
) after validating the string as JSON. Make sure what the server sends you back by calling:
$.get(url, callback, 'text');
and lookup the response data within the callback.
Here you go fella :) Assign data from jQuery getJSON to array
精彩评论