Here is my JSON string.... which I can't modify because it comes from a database query from ColdFusion:
{
"Modules": {
"COLUMNS": [
"MODULECODE",
"MODULETITLE"
],
"DATA": [
[
"A001",
"The Middle Ages"
],
[
"M001",
"Civil Liberties"
],
[
"H001",
"Project Preparation"
]
]
},
"Courses": {
"COLUMNS": [
"COURSETITLE",
"COURSECODE"
],
"DATA": [
[
"Marketing",
"00007001"
],
[
"Fashion and Textile Buying Management",
"00006002"
]
]
}
}
Here is my JQuery code to try to extract out the data in order to populate SELECT form element:
$(document).ready(function() {
$('#UserCode').blur(function() {
$.ajax({
type: 'get',
url: 'mydata.cfc',
data: {method:'getData', UserCode:$(this).val()},
dataType: 'json',
success: function(result){
$.each(result, function(index, valueA){
$.each(valueA, function(index, valueB){
// Trying to append to the #Courses <select> element
$('#Courses').append('<option value="'+valueB[1]+'">'+valueB[2]+' ('+valueB[1]+')</option>');
});
});
}
});
});
});
Basically I don't have a clue how to get the "Courses" data into the #Courses select element for now. Later I will also need to create a #Modules select element and do the same thing with the "Modules" data.
There are arrays within arrays and I don't understand how to ask JQuery to just select "valueB.Courses" for example. I have got about 5 Jquery books but their example JSON strings do not have arrays of arrays like mine so I can't figure what to do :(
valueB.Courses.DATA[1][0] == "Fashion and Textile Buying Management"