Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:27:06+00:00 2026-06-17T08:27:06+00:00

Node.js server var http = require(http); http.createServer(function(request,response){ console.log(client connected); response.writeHeader(200,{Content-type: text/html}); response.write(Hello ;-)); response.end();

  • 0

Node.js server

var http = require("http");
http.createServer(function(request,response){
    console.log("client connected");
    response.writeHeader(200,{"Content-type": "text/html"}); 
    response.write("Hello ;-)");
    response.end();
}).listen(9090);

I try to load the server output into a div with the ID “myDisplayField”:

$("#myDisplayField").load("http://localhost:9090");

(The HTML-File lies on my local httpd)

The issu I’m having with that is that the node server may show that he got a request from ajax (“client connected”), but “Hello ;-)”/the site content doesn’t get loaded into #myDisplayField as expteced.

If I set up a webserver like Apache and put a index.html with “Hello ;-)” in htdocs, the whole thing works just fine.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:27:07+00:00Added an answer on June 17, 2026 at 8:27 am

    I just tried your code, and navigating to localhost:9090 displays the ‘hello’ body as expected.

    It may be that jquery’s load() method looks for other data – for example, content-type in the header – that your very simple response doesn’t provide. Instead of building every http response individually, you should use a higher-level server like express:

    var express = require('express');
    var app = express();
    
    app.use(function(req, res, next) {
      res.send('Hello');
    });
    
    app.listen(9090);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple node js http server. var http = require(http); http.createServer(function(request, response) {
I have the following node.js server-side code: var app = require('http').createServer(handler) , io =
Here is a simple webserver I am working on var server = require(http).createServer(function(req,resp) {
Given code like this from a node.js neophyte like me: require('http').createServer(function( req, resp )
I have written a http server using node js var sys = require(sys), http
I have the following simple http server using Node.js: var http = require('http'); var
Nodejs version: 0.8.8 Here is the server: var http = require('http'); var port =
I have created a nodejs http server var http = require(http); var url =
I'm testing out nodejs (0.8.11). with the following server app: var http = require('http');
On my node.js server I have the following code: //Generate a token var token

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.