I have the following code in my client which is executed on page load. My client pages and JS are hosted by mode my Node.js script with Express
initHomePage : function(options) {
$.getJSON('siteinfo.json',
function(data) {
//called when complete
alert('process complete' + data);
});
},
Which is calling the following 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]));
}
}
};
My console.log is firing and showing my expected JSON in the console when I expect the the request to be made.
However the alert box that pops up in my browser says
"process complete[object Object]"
Why is my JSON not passing from my server side to my client script?