0

Inside the below job.js node script how can i call /getJobs .Am using following way but getting $ is not defined.

job.js

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

script.js

.......
......
 switch(context.pathname) {
        case '/getJobs':
          testUtils.runTest(context);
          break; 
}
2
  • $.get() looks like a jQuery method. Have you included jQuery? Commented Nov 13, 2013 at 8:13
  • Not inclued jquey.it is a node script.i tried this way.coz i dont know how to call that/getjobs in node.js Commented Nov 13, 2013 at 8:16

1 Answer 1

1

You need request module. It will help you to make http requests:

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.
  }
})
Sign up to request clarification or add additional context in comments.

4 Comments

is it suitable for /getjobs also?
@Sush What is /getjobs?
in jquey am using $.get('/getJobs', params, function (data) { console.log(data); }); like this.but i want to call this from node.js
What you are doing is just a simple ajax (GET request). What I'm suggesting is a nodejs module which does the same thing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.