I'm trying to add Jquery on my server.js. I'm using windows 8 as my server. I'm performing a AJAX call with jquery on nodejs. My server would actually load a JSON data from YAHOO. i got my port 5555
I run the commandprompt on and type
npm install jquery
Then:
node server.js
Here is my server.js
var $ = require('jquery');
var http = require("http")
, fs = require("fs")
, qs = require("querystring")
, port = 5555
var server = http.createServer(function(request, response) {
$.getJSON( 'http://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.historicaldata where symbol = 'AAL'&format=jsonstore://datatables.org/alltableswithkeys
', cbFunc);
});
function cbFunc(data){
console.log(data);
}
server.listen(port);
console.log('Server is listening to http://localhost/ on port ' + port + '...');
Anyone can help me in my problem. Thanks in advance!
Please ignore the URL because that's just a sample and its working on my YAHOO URL
npm install request
then:
var request = require('request');
request.get(myUrl, { json: true }, function(err, res) {
// handle res data here
})