Tip: Click lines to highlight, hold ctrl/cmd to multi-select
Build Options html from json response (18-Jan @ 14:35)
Syntax Highlighted Code
- //return JSON Object
- $.getJSON(selectedInstrumentAjaxCallUrl, {instrument:ticker}, function(json) {
- //build options html
- var optionsHtml = '';
- for (var i = 0; i < json.length; i++) {
- optionsHtml += '<option value="' + json[i].optionValue + '">' + json[i].optionDisplay + '</option>';
- }
- $("#select1").html(optionsHtml);
- $("span.ajax-load").remove();
- $("#select1").removeAttr("disabled");
- $('#select1 option:first').attr('selected', 'selected');
- })
- })
Plain Code
//return JSON Object
$.getJSON(selectedInstrumentAjaxCallUrl, {instrument:ticker}, function(json) {
//build options html
var optionsHtml = '';
for (var i = 0; i < json.length; i++) {
optionsHtml += '<option value="' + json[i].optionValue + '">' + json[i].optionDisplay + '</option>';
}
$("#select1").html(optionsHtml);
$("span.ajax-load").remove();
$("#select1").removeAttr("disabled");
$('#select1 option:first').attr('selected', 'selected');
})
})