Trouble populating a selectlist from returned json

Hi,
I have some json being returned that looks like this (partial)
{"models":[{"id":"Cadillac_ATS","name":"ATS","niceName":"ats","years":[{"id":100536829,"year":2013,"styles":[{"id":200420764,"name":"Luxury 4dr Sedan (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Luxury"},{"id":200420763,"name":"Luxury 4dr Sedan (2.5L 4cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Luxury"},{"id":200420762,"name":"Luxury 4dr Sedan (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Luxury"},{"id":200420761,"name":"Standard 4dr Sedan (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Standard"},{"id":200420768,"name":"Performance 4dr Sedan (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Performance"},{"id":200420767,"name":"Luxury 4dr Sedan AWD (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Luxury"},{"id":200420766,"name":"Performance 4dr Sedan (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Performance"},{"id":200420765,"name":"Luxury 4dr Sedan AWD (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Luxury"},{"id":200420760,"name":"Standard 4dr Sedan AWD (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Standard"},{"id":200420773,"name":"Premium 4dr Sedan (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Premium"},{"id":200420774,"name":"Premium 4dr Sedan AWD (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Premium"},{"id":101401799,"name":"Standard 4dr Sedan (2.5L 4cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Standard"},{"id":200420769,"name":"Performance 4dr Sedan AWD (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Performance"},{"id":200420770,"name":"Premium 4dr Sedan (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Premium"},{"id":200420771,"name":"Performance 4dr Sedan AWD (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Performance"},{"id":200420772,"name":"Premium 4dr Sedan AWD (2.0L 4cyl Turbo 6A)","submodel":{"body":"Sedan","modelName":"ATS Sedan"},"trim":"Premium"}]}]},{"id":"Cadillac_CTS","name":"CTS","niceName":"cts","years":[{"id":200427161,"year":2013,"styles":[{"id":200427168,"name":"Performance 4dr Sedan AWD (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"CTS Sedan"},"trim":"Performance"},{"id":200427167,"name":"Performance 4dr Sedan (3.6L 6cyl 6A)","submodel":{"body":"Sedan","modelName":"CTS Sedan"},"trim":"Performance"},...

Open in new window

I'm trying to get at first the 'name' of each vehicle model (first one being ATS) and then add on the 'years.styles.name'. So the first couple results in my select list would be:

ATS Luxury 4dr Sedan (3.6L 6cyl 6A)
ATS Luxury 4dr Sedan (2.5L 4cyl 6A)

and so on...

<script type="text/javascript" charset="utf-8">

$("select[name='newmake']").change( function () {
	$.post("trades/get_models/",{ year: $("select[name='newyear']").val(),make: $("select[name='newmake']").val() },
	function(data){
		var $select = $('#newmodel');
        $.each(data, function () {
        var thevehicle = data.models.name + " " + data.models.years.styles.name;
		$select.append($('<option></option>').attr("value", thevehicle).text(thevehicle));
        
        });
	},
    'json');
  });
</script>

Open in new window

Any help would be much appreciated.
LVL 1
tjyoungAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Can you please set up the SSCCE with a working JSON string?  Then we would be able to test the JavaScript and give a better answer.
0
tjyoungAuthor Commented:
This may help to shed some light. Its still not working but should be easier to make heads/tails out of:

Fiddle
I'm basically trying to get 'anything' into the select list at the moment.
0
tjyoungAuthor Commented:
I've got it pretty close to populating but I'm missing something.
I've updated the fiddle to show:

Fiddle example
0
tjyoungAuthor Commented:
Was solved.
final fiddle
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tjyoungAuthor Commented:
Found answer I was looking for elsewhere. Thanks regardless.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.