Hoi,
Ben een beetje aan het klote met nodeJS. Alleen heb ik een raar probleem, het zo gewoon moeten werken:
Code:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Include http module.
var http = require("http");
// Create the server. Function passed as parameter is called on every request made.
// request variable holds all request parameters
// response variable allows you to do anything with response sent to the client.
http.createServer(function (request, response) {
// Attach listener on end event.
// This event is called when client sent all data and is waiting for response.
request.on("end", function () {
// Write headers to the response.
// 200 is HTTP status code (this one means success)
// Second parameter holds header fields in object
// We are sending plain text, so Content-Type should be text/plain
response.writeHead(200, {
Content-Type: text/plain
});
// Send data and end response.
response.end(Hello HTTP!);
});
// Listen on the 8080 port.
}).listen(8080);
console.log("Ready!");
cmd:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (img163.imageshack.us).Bron openen ↗
Maar als ik naar http://localhost:8080/ ga blijft de pagina maar door laden tot dat ie Geen gegevens ontvangen zegt, wanneer ik de pagina laad en CMD sluit komt er Deze webpagina is niet beschikbaar.
Hij maakt dus wel verbinding maar waarom komt er geen Hello HTTP te staan?
toevoeging op 11 december 2013, 19:06:23:
TUT: http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/
toevoeging op 11 december 2013, 19:30:36:
Werkt al:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
var http = require("http");
http.createServer(function(request, response) {
response.write("Hello World");
response.end();
console.log("New connection!");
}).listen(8888);
console.log("Ready!");
Ben een beetje aan het klote met nodeJS. Alleen heb ik een raar probleem, het zo gewoon moeten werken:
Code:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Include http module.
var http = require("http");
// Create the server. Function passed as parameter is called on every request made.
// request variable holds all request parameters
// response variable allows you to do anything with response sent to the client.
http.createServer(function (request, response) {
// Attach listener on end event.
// This event is called when client sent all data and is waiting for response.
request.on("end", function () {
// Write headers to the response.
// 200 is HTTP status code (this one means success)
// Second parameter holds header fields in object
// We are sending plain text, so Content-Type should be text/plain
response.writeHead(200, {
Content-Type: text/plain
});
// Send data and end response.
response.end(Hello HTTP!);
});
// Listen on the 8080 port.
}).listen(8080);
console.log("Ready!");
cmd:
Afbeelding niet beschikbaarDe bron kon niet worden geladen (img163.imageshack.us).Bron openen ↗Maar als ik naar http://localhost:8080/ ga blijft de pagina maar door laden tot dat ie Geen gegevens ontvangen zegt, wanneer ik de pagina laad en CMD sluit komt er Deze webpagina is niet beschikbaar.
Hij maakt dus wel verbinding maar waarom komt er geen Hello HTTP te staan?
toevoeging op 11 december 2013, 19:06:23:
TUT: http://net.tutsplus.com/tutorials/javascript-ajax/node-js-for-beginners/
toevoeging op 11 december 2013, 19:30:36:
Werkt al:
Codeblok (voorbeeld.php):
1
2
3
4
5
6
7
8
9
var http = require("http");
http.createServer(function(request, response) {
response.write("Hello World");
response.end();
console.log("New connection!");
}).listen(8888);
console.log("Ready!");