[jQuery] Re: extract data from this JSON encode using jQuery

2009-06-29 Thread Mean Mike
what I do is use addOption see http://www.texotela.co.uk/code/ jquery/select/>here $("#albums").addOption(data.albums, false); my json response looks like this {"albums":{"13":"Horses","10":"Lambs\/Sheep","12":"Cows","14":"Other animals"}} Mean Mike On Jun 29, 10:13 am, Alexandre Magno wr

[jQuery] Re: extract data from this JSON encode using jQuery

2009-06-29 Thread Alexandre Magno
Ricardo, The code it's still heavy, you are appending in each loop, this is not a good code pratice for perfomance and if you read the reference I passed, you will see that it's not so relevant. The code extract states, it can deal with a lot of data and the perfomance should be a item to conside

[jQuery] Re: extract data from this JSON encode using jQuery

2009-06-27 Thread Ricardo
For adding a handful of options in a select performance is almost irrelevant, it's more than fast enough. You can improve code readability and performance (a bit) using the Option constructor: $.post('/path/to/json.php', {params: 'xxx'}, function(data){ var $select = $('#mySelectBox'); $.

[jQuery] Re: extract data from this JSON encode using jQuery

2009-06-26 Thread Alexandre Magno
Hello, Yeah, thats right, the code works but it's too heavy You should concatenate one string with all option and then make a append. A append inside the loop would break the perfomance: > $.post('/path/to/json.php', {params: 'go here, if you need them'}, > function(data){ > // "data" conta

[jQuery] Re: extract data from this JSON encode using jQuery

2009-06-26 Thread Eric Garside
Well, lets assume you're getting the JSON you described from the following ajax call: $.post('/path/to/json.php', {params: 'go here, if you need them'}, function(data){ // "data" contains that JSON object you described // Also, I'm assuming your select box looks something like this: //