I just installed Node JS on my ec2 instance (server) using the following site...http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/
I followed the instructions and I believe I downloaded it all properly, now I am trying to implement Node, but I do not think I am doing it right. I tried tutorialspoint.com but still cannot get it to work.
Basically I am using AJAX when a button is clicked, which in turn calls my node file...
$('#savePic').click(function(e)
{
$.ajax({
url: "signupServer.js",
type:'POST',
data: new FormData($('#formpic')[0]),
contentType: false,
processData: false
}).done(function(){
and my node js file looks like this...
var http = require("http");
var fs = require("fs");
http.createServer(function (request, response) {
fs.writeFile("var/www/html/uploads/test", "Hey there!", function(err) {
if(err) {
return console.log(err);
}
console.log("The file was saved!");
});
I am not using any of the POST
data as referenced in my AJAX, I am simply using AJAX to call the code written in my signupServer.js
.
The node js file above simply writes "Hey there!"
to a file called test located at /var/www/html/uploads/test
, but I cannot get it to work. I don't think anything is happening when the button savePic
is clicked. Am I using node wrong here?