> ... how much functionality Quickbase has when it comes to injecting code ...
Once you get to script you
exceed the functionality of QuickBase and anything is possible.
If you write your code like this you will return
JSON instead of
XML and you will not have to process each record with
$().each(...):
(function() {
var dbid = "<your application dbid>";
var dbidTable = "bm9rx6w83";
var apptoken = "tvy5zcdaqafyfxp43vhd78gyys";
$.ajaxSetup({data: {apptoken: apptoken}});
var XMLFlatToObj = function(xml, type) {
var data = [];
var record = {};
$("record", xml).each(function() {
record = {};
$(this).children().each(function () {
record[$(this).prop("tagName")] = $(this).text();
});
data.push(record);
});
return {records: data};
}
var promise = $.ajax({
url: dbidTable,
data: {
act: "API_DoQuery",
query: "{20.GT.1000}",
clist: "a",
options: "sortorder-D"
},
dataFilter: XMLFlatToObj
});
var promise = $.post(dbidTable, {
act: "API_DoQuery",
query: "{20.GT.1000}",
clist: "a",
options: "sortorder-D"
})
promise.then(function(response) {
console.log(JSON.stringify(response, null, " "));
});
})();
To gather
JSON from multiple
AJAX calls you simply create additional
promises and with a
$.when(promise1, promise2, promise3 ...) call you can merge the individual
JSON responses together into one overall JSON structure using
$.extend(). The combined
JSON can be then summarized using underscore's
_.groupBy() method and templated to HTML using underscore's
_.template() method.