I am new to node, so please bear with me. I'm trying to write a function that tests to make sure there is a live connection to the web server before redirecting the page.
This works for the first 6 - 7 clicks, then the page will not redirect anymore - it just sits there. Then a few minutes later, an alert will show.
What is going on?!
var http = require("http");
var url = 'http://example.com/';
mainMenu.click(function () {
var menulink = $(this).attr('rel');
var menuvar = http.get(url, function () {
window.location = menulink;
}).on('error', function () {
alert('Cannot Connect to Server');
});
});