Skip to content

Instantly share code, notes, and snippets.

@huoxito
Created September 23, 2011 22:49
Show Gist options
  • Save huoxito/1238659 to your computer and use it in GitHub Desktop.
Save huoxito/1238659 to your computer and use it in GitHub Desktop.
jquery json example
$(document).ready(function(){
$('#marca').change(function(){
var marca = $('#marca option:selected').val();
$.getJSON('static/javascripts/models/models?marca', function(json){
var items = '';
$.each(json, function(idx,value) {
if(marca == value['make']){
items += '<option value="' + value['model'] + '">' + value['model'] + '</option>';
}
});
$('#model').html(items);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment