你这个:client.query是ajax操作的吧。那你在后台把查询的结果集取出来,用json的形式吧,然后,在前台的回调函数中去取你想要的东西。

解决方案 »

  1.   

    不是ajax,是nodejs的,JavaScript用来做服务器语言,你的想法是对的!最终我也是添加了一个回调函数,来通过回调函数获取返回结果!
      

  2.   

    var async = require('async');
    async.series([
            function (callback) { 
    var values = ['Chad', 'Lung', 'Hello World'];
      client.query('INSERT INTO MyTable SET firstname = ?, lastname = ? , message = ?', values,
        function(error, results) {
          if(error) {
            console.log("ClientReady Error: " + error.message);
            client.end();
            return;
          }
          console.log('Inserted: ' + results.affectedRows + ' row.');
          console.log('Id inserted: ' + results.insertId);
          callback(null,1);
        }
      ); },
            function (callback) {
            GetData(client);
            callback(null,1);}],
     function (err, results) {
                return;
            });
    这样就可以串行了