开发者

format which support flash

开发者 https://www.devze.com 2023-02-08 16:29 出处:网络
I have an json which stored as toc.js for eg the json is like this [{ \"id\":\"205\",\"name\":\"apple\", \"description\":\"fruit\"},

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

0

精彩评论

暂无评论...
验证码 换一张
取 消