Click here to Skip to main content
15,897,891 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: need help understanding how regular updating of a div works Pin
ZurdoDev15-Jul-16 2:26
professionalZurdoDev15-Jul-16 2:26 
QuestionNeed help understanding this piece of code Pin
Jaime Premy10-Jul-16 5:53
professionalJaime Premy10-Jul-16 5:53 
AnswerRe: Need help understanding this piece of code Pin
ZurdoDev15-Jul-16 2:31
professionalZurdoDev15-Jul-16 2:31 
GeneralRe: Need help understanding this piece of code Pin
Jaime Premy15-Jul-16 5:21
professionalJaime Premy15-Jul-16 5:21 
GeneralRe: Need help understanding this piece of code Pin
ZurdoDev15-Jul-16 5:26
professionalZurdoDev15-Jul-16 5:26 
GeneralRe: Need help understanding this piece of code Pin
Jaime Premy16-Jul-16 18:22
professionalJaime Premy16-Jul-16 18:22 
GeneralRe: Need help understanding this piece of code Pin
ZurdoDev17-Jul-16 8:19
professionalZurdoDev17-Jul-16 8:19 
QuestionWhat is the work of callback argument in NodeJs "module.exports"? Pin
MaxySpark4-Jul-16 10:03
MaxySpark4-Jul-16 10:03 
I’m learning nodeJS.

I don’t know what is the purpose of
JavaScript
callback
argument in
JavaScript
module.exports
. It pretty much look like
JavaScript
return
and
JavaScript
console.log


here is my code

JavaScript
var request = require('request');




module.exports = function(location,callback) {

    var encodedUrl = encodeURIComponent(location);
    //set url
    var url = "http://api.openweathermap.org/data/2.5/weather?q="+encodedUrl+"&APPID=575991c6b55a139d32139652d78bc8b8&units=metric";
//location check
    if(!location) {
        callback("No location provided");
    } else {
        callback('location is '+location);
    }

//request
request({
    url: url,
    json: true
}, function (error,response, body) {
   if(error) {
       callback('Unable To Fetch Weather');
   } else {
       //console.log(JSON.stringify(body, null, 4));
       callback("Current Temperature in "+body.name+" "+body.main.temp + '\xB0!!!');
   }
});
};

AnswerRe: What is the work of callback argument in NodeJs "module.exports"? Pin
rah_sin12-Jul-16 0:42
professionalrah_sin12-Jul-16 0:42 
QuestionForming your own panel Pin
Member 126139631-Jul-16 3:06
Member 126139631-Jul-16 3:06 
AnswerRe: Forming your own panel Pin
Richard MacCutchan1-Jul-16 3:48
mveRichard MacCutchan1-Jul-16 3:48 
QuestionError in parentNode.replaceChild while hiding content which is available in web page Pin
srikrishnathanthri1-Jul-16 2:41
srikrishnathanthri1-Jul-16 2:41 
QuestionChange webpage background on the fly (If it worked) Pin
Born5929-Jun-16 2:00
Born5929-Jun-16 2:00 
AnswerRe: Change webpage background on the fly (If it worked) Pin
Richard Deeming29-Jun-16 2:06
mveRichard Deeming29-Jun-16 2:06 
PraiseRe: Change webpage background on the fly (If it worked) Pin
Born5929-Jun-16 2:12
Born5929-Jun-16 2:12 
QuestionJSHint & Sublime use and config Pin
DavidMillar246828-Jun-16 21:00
DavidMillar246828-Jun-16 21:00 
AnswerRe: JSHint & Sublime use and config Pin
Richard MacCutchan28-Jun-16 21:20
mveRichard MacCutchan28-Jun-16 21:20 
AnswerRe: JSHint & Sublime use and config Pin
Kornfeld Eliyahu Peter28-Jun-16 22:55
professionalKornfeld Eliyahu Peter28-Jun-16 22:55 
QuestionConfirm always returning false on Firefox for IOS Ver 4.0 Pin
jkirkerx23-Jun-16 12:35
professionaljkirkerx23-Jun-16 12:35 
AnswerRe: Confirm always returning false on Firefox for IOS Ver 4.0 Pin
Graham Breach23-Jun-16 23:17
Graham Breach23-Jun-16 23:17 
GeneralRe: Confirm always returning false on Firefox for IOS Ver 4.0 Pin
jkirkerx24-Jun-16 6:10
professionaljkirkerx24-Jun-16 6:10 
GeneralRe: Confirm always returning false on Firefox for IOS Ver 4.0 Pin
Graham Breach24-Jun-16 23:54
Graham Breach24-Jun-16 23:54 
GeneralRe: Confirm always returning false on Firefox for IOS Ver 4.0 Pin
jkirkerx26-Jun-16 9:01
professionaljkirkerx26-Jun-16 9:01 
QuestionJQuery Validator, rules highlight creates label under textbox that is wrong class. Pin
jkirkerx22-Jun-16 9:34
professionaljkirkerx22-Jun-16 9:34 
AnswerRe: JQuery Validator, rules highlight creates label under textbox that is wrong class. [solved] Pin
jkirkerx22-Jun-16 12:34
professionaljkirkerx22-Jun-16 12:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.