CNode

node.js mysql数据查询 返回值问题

问答
Xxiaoxi--发布于12 年前最后回复12 年前2 回复11397 浏览0 收藏

var crypto = require('crypto'); var http = require('http'); var fs = require('fs'); var mysql = require('../models/db.js');

exports.backfind = function(req, res) { var input=req.body.input; var startdate=req.body.startdate; var enddate=req.body.enddate; var input1=parseInt(req.body.input1);

if (input==1) { mysql.query('select city from xiao ORDER BY City DESC limit 0,10',function(err,rows,fields){ if (err) { return res.send('1'); } if (rows) { //console.log(rows) return res.send ('2'+rows) } }) }else{ return res.send('3'); } };

exports.backfindp = function(req, res) { res.render('901',{title:'897157'}); };

web页面返回值为:2[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

查看回复

回复 (2)

A
alsotang#1·12 年前

('2'+rows) 这句改成 ('2'+JSON.stringify(rows))

X
xiaoxi--#2·12 年前
引用 alsotang('2'+rows) 这句改成 ('2'+JSON.stringify(rows))

@alsotang 可以啦,谢谢你,非常感谢

参与回复
登录后即可参与回复。登录