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 9226289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:47:37+00:00 2026-06-18T04:47:37+00:00

Alright, so when I run this server: var net = require(‘net’); var server =

  • 0

Alright, so when I run this server:

var net = require('net');

var server = net.createServer(function (data) {
    console.log("Hello " + data.name);
});

server.listen(1337, '127.0.0.1');

and then browse this page on chrome (from a file, not a domain):

<!DOCTYPE html>
<html lang="en">
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            var data = new function(){
                this.name = "John";
            };

            $.post('http://127.0.0.1:1337/', data);
        </script>
    </head>
    <body>

    </body>
</html>

I get the following output on my server:

Hello undefinied

My question is, why does my data object’s name become undefined when I send it to the server?


Edit: So I changed my server to this:

var http = require('http');

var server = http.createServer(function (data) {
    console.log("Hello " + data.name);
});

server.listen(1337, '127.0.0.1');

and changed my client’s script to this:

var data = {
                name: "John"
            };
            $.post('http://127.0.0.1:1337/', data);

But I’m still getting the same error.

  • 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-18T04:47:38+00:00Added an answer on June 18, 2026 at 4:47 am

    net.connection creates a plain TCP socket, not an HTTP server.

    You want http.createServer instead, and the function it accepts as its argument doesn’t get a simple object containing just the submitted data. You need to read the manual for the http module and see how to process a request object.

    There is an example on the node.js homepage (just scroll down).

    See also the API docs for request events and node.js Extracting POST data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright well, I connect to 3 different ip's when I run this script. It
Alright, this one's been puzzling me for a bit. the following function encodes a
Trying to run php app\console doctrine:schema:update --force . I Catch this error: In parameters.ini
Alright, this has got me stumped. I have this function: tf <- function(formula =
I am trying to run a Perl SOAP server, it starts up alright, but
Alright guys, this should be a very simple request. I'd like to run a
I'm new to objective-c and ios, but I'm coming along alright. Now I've run
Alright I don't see why this isnt working. It seems pretty simple. Here is
Alright, this is driving me nuts because my regex is working on Rubular, but
Alright so I have no idea how to even begin doing this But basically

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.