Wednesday, 10 May 2017

Send array value on Javascript but it show as [object Object]

I count number of result from database and send as 'TotalItems'

mysql_crawl.query('SELECT COUNT(*) FROM `catalogsearch_fulltext` WHERE MATCH(data_index) AGAINST("'+n+'") ', function(error, count) {
    var r = count[0];
    var totalItems = r,
    res.render('result.html', {
                totalItems: totalItems
                })
    });

I try running console.log on r, result is

RowDataPacket { 'COUNT(*)': 25 }

but when I run <% totalItems %> on javascript, it show as

[object Object]

How can I show object as number?



via Moomoo Soso

No comments:

Post a Comment