抱歉如果我还没在文件里找到它..。
问:在Railo中如何更改ajax调用的查询格式?这是我的组成部分:
component {
remote function Read() returnformat='json' {
svc = new Query();
svc.setSQL("SELECT * FROM INFORMATION_SCHEMA.TABLES");
obj = svc.execute();
local.result.Prefix = obj.getPrefix();
local.result.qry = obj.getResult();
url.queryFormat = "column";
return local.result;
}
}这是我的JavaScript:
(function() {
var local = {};
local.type = 'POST';
local.url = 'AJAX.cfc';
local.dataType = 'json';
local.data = {};
local.data.method = 'Read';
local.Promise = $.ajax(local);
local.Promise.done(done);
local.Promise.fail(fail);
function done(response) {
console.log(response);
debugger;
}
function fail(xhr,status,response) {
debugger;
}
})();我要回来的是:
response.qry.DATA[] // 57 arrays, each of length 4但是ColdFusion返回它,我已经非常喜欢使用它(能够使用列名而不是数组位置):
response.qry.DATA.TABLE_CATALOG[] // An array of 57 elements
response.qry.DATA.TABLE_SCHEMA[]
response.qry.DATA.TABLE_NAME[]
response.qry.DATA.TABLE_TYPE[]发布于 2014-02-13 19:41:33
对函数使用ReturnFormat=“平原”,并为serializeJson()的第二个参数传递true
serializeJson(Query, true)这将为您提供一个按列序列化的JSON对象,因此您只需返回它。
https://stackoverflow.com/questions/21742807
复制相似问题