Monday 19 December 2016

Node js express app not responding to ajax call

I've looked everywhere and I cannot find a similar problem to mine. I make an ajax call on a webpage to url localhost:80 or http://127.0.0.1:80, or similar. I have a node.js application listening on port 80 and when I press the button on my webpage the ajax call goes off fine but nothing happens on my node js app, it does not do anyhting even though I am sending the call on the right port. I have no idea what to do.Ajax call:$(document).ready(function () { $("#getimage").on('click', function () { window.alert("Working!"); $.ajax({ type: 'POST', url: 'http://localhost:80', success: success(), error: function() { $('#notification-bar').text('An error occurred'); } }); }); }); NodeJs app eaiting on port 80:var server = app.listen(80, function () { var host = server.address().address; var port = server.address().port; console.log("Example app listening at http://%s:%s", host, port); }); I run the node application and it sits there waiting to reply to the ajax call but nothing happens when I press the button, what am I doing wrong? Im using a wamp server on my local machine and the port on Apache is 80, I made sure the ajax call is working.

Submitted December 20, 2016 at 06:52AM by Jarmahent

No comments:

Post a Comment