So I have a $.post, that returns some json_encode($array);
$array is one dimensional, and it contains numbers: 2, 4, 6.
So now data is holding the json data, how can I loop through and make options to my #time selector? The value="" and display text should be the number from the array.
Something like that should work:
DEMO: http://jsfiddle.net/tmSqR/
UPDATE. Your data is not decoded from string format to JSON. Either add
dataTypeproperty to$.post, or usedata = JSON.parse(data)before making iteration.DEMO: http://jsfiddle.net/tmSqR/1/