lundi 26 janvier 2015

Returning a result from an AJAX Node.js GET request


Vote count:

0




I need to verify that a URL leads to a valid page. I am doing this by checking that the status code is 200. I spoke to people about dealing with AJAX, and they all said to use callbacks. Apparently this doesn't work either. The code does not return anything. I have no idea how to get around this.



function httpRequest(callback) {
http.get(options, function(res) {
if (res.statusCode == 200) {
callback(true);
}
});
}


httpRequest(function(result) {
console.log(result);
return result;
});


asked 1 min ago







Returning a result from an AJAX Node.js GET request

Aucun commentaire:

Enregistrer un commentaire