node.js - 原生nodejs怎么把数据库里接收到的数据传给前端
伊谢尔伦
伊谢尔伦 2017-04-17 16:07:48
0
1
402

萌新求教:
//执行查询

    connection.query('select * from newslist where sort=?', [sort], function (err, rs) {
        if (err) {
            console.log('[query] - :' + err);
            return;
        }
        console.log('--------------------------result----------------------');
        for (var i = 0; i < rs.length; i++) {
            console.log('The solution is: ', rs[i]);
        }
        console.log('--------------------------result----------------------');
    });

怎么把上面操作获取到的结果rs 传给前端(是用AJAX写的,上面代码仅仅是console.log可以在cmd控制台打出来)

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(1)
小葫芦

If it is passed to the front end through ajax, the relevant interface needs to be defined for the front end to access. Then put the operation of querying data in the interface. You can refer to my small project
https://github.com/ermu592275...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template