我的客戶端中有以下代碼,這是在頁面加載時執行的。我的客戶頁面和JS通過託管模式Node.js的我的腳本快捷JSON沒有從Node.js傳遞到.getJSON
initHomePage : function(options) {
$.getJSON('siteinfo.json',
function(data) {
//called when complete
alert('process complete' + data);
});
},
這是調用下面的Node.js
exports.get_site_setup = function (req, res) {
var dbc;
async.waterfall([
// get a connection
function (callback) {
db.db(callback);
}
,querylookup
], completed);
function querylookup(dbclient, callback) {
dbc = dbclient;
dbc.query("SELECT site_id, "+
"name, "+
"quicklist, "+
"image, "+
"image2, "+
"message, "+
"fbflag, "+
"facebookurl, "+
"twflag, "+
"twitterurl, "+
"contactflag, "+
"contactemail, "+
"eventsflag, "+
"loyaltyflag, "+
"loyaltyclub, "+
"loyaltymessage, "+
"location_id, "+
"locdescription "+
"FROM LOCATION_LOOKUP_ACTIVE_VIEW "+
"where site_id = 7 and location_id = 8",
callback);
}
function completed (err, rows, fields) {
if (dbc) dbc.end();
if (err) {
callback (err);
} else {
console.log(rows[0]);
res.contentType('json');
res.send(JSON.stringify(rows[0]));
}
}
};
我的console.log被解僱,並顯示在我的預期JSON控制檯,當我期望的要求作出。
然而,在我的瀏覽器彈出警告框說
「的過程完成的翻譯:」
爲什麼不從我的服務器端傳遞給我的客戶端腳本我的JSON?
'({})的toString()' – MMM