0

在下面的job.js节点脚本中,我如何调用/getJobs。我使用以下方式但得到$ is not defined.

job.js

var jobScedule = function (time, jobid) {
var params = {
            "id": jobid
        };
          $.get('/getJobs', params, function (data) {
            console.log(data);
        });
}

脚本.js

.......
......
 switch(context.pathname) {
        case '/getJobs':
          testUtils.runTest(context);
          break; 
}
4

1 回答 1

1

您需要请求模块。它将帮助您发出 http 请求:

var request = require('request');
request('http://www.google.com', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body) // Print the google web page.
  }
})
于 2013-11-13T08:18:10.773 回答