var db_options={ host:’localhost’, port : 3308, user : 'root’, password : ‘’, database:’mysql’ } var mq = require(“mysql”); var mc = mq.createConnection(db_options); mc.connect();
exports.getName = function(req, res) { var username = req.body[“name”];
var sql = "select name from `user` where name = " + username;
mc.query(sql, function(err, rs, fields){
mc.end();
mc.destroy()
var info="123";
if(err){
info = "系统异常";
mc.end();
mc.destroy()
}
console.log(info);
console.log(rs);
res.write(JSON.stringify(rs));
//console.log(JSON.stringify(rs));
});
};
我只是想写 用户名重复验证 $.ajax() 为什么会出现这样的问题!