例如,我有一個從福特和大衆汽車的JSON文件。現在我有一個var'福特'或'大衆汽車'存儲的變種。我如何結合數據選擇使用這個var。jQuery Mobile getJSON獲取數據與var
$.getJSON('file.json', function(data) {
$.each(data.ford, function(i, item) {
//do something
});
});
$.getJSON('file.json', function(data) {
$.each(data.volkswagen, function(i, item) {
//do something
});
});
我的意思是這樣
var brand = 'ford';
data.+brand