1

请帮我。我的搜索使用帖子中需要变量:

app.post('/find', function(req, res) {
    var id_school = req.body.std_id;
    console.log('show '+ id_sekolah);
    db.collection('ak_test_score', function(err, collection) {
        collection.find({'std_id':id_school}).toArray(function(err, level) {
            var a = level.std_id;
            var b = level.school_name;
        });
    });
    res.redirect('/test_score'); // send to my page to get
};

var test = a;  // not defined variable a not have

app.get('/test_score', function(req, res) {
    var id_school = test;
    console.log('show '+ id_sekolah);
    db.collection('ak_test_score', function(err, collection) {
        collection.find({'std_id':id_school}).toArray(function(err, level) {
             res.send(level)
        });
    });
};

我正在使用它来使用帖子进行网站搜索。

4

1 回答 1

0
app.post('/find', function(req, res) {
   var id_school = req.body.std_id;
   console.log('show '+ id_sekolah);
   db.collection('ak_test_score', function(err, collection) {
      collection.find({'std_id':id_school}).toArray(function(err, level) {
        var a = level.std_id;
        app.set('data',a);
        var b = level.school_name;

        });
});
   res.redirect('/test_score'); ///// send to my page to get
};


 app.get('/test_score', function(req, res) {
    var id_school = app.get('data');
    console.log('show '+ id_sekolah);
    db.collection('ak_test_score', function(err, collection) {
      collection.find({'std_id':id_school}).toArray(function(err, level) {
           res.send(level)
        });
});

};
于 2013-08-01T07:13:39.677 回答