JavaScript:node.js HTTP GET

On the HTML side, when I press a button, the following is script is called:

$("form").submit(function(f) {
    f.preventDefault();
    $.ajax({
        url: "/example",
        data: "name=Mr_Skid_Marks",
        type: "GET",
        success: function(data) {
            //do something with data
        },
        error: function(e) {
            //bad news
        }
    });
});

On the node.js side, I am trying to retrieve the name field in the HTTP request handler:

var queryData = url.parse(req.url, true).query;
var nameVal = queryData.name;

response.setHeader('Content-Type', 'application/json');
response.end(JSON.stringify({name: nameVal}));

I able to retrieve the name field if the data is typed into the url, ie: localhost:1111/html_file.html?name=Mr_Skid_Marks, but the problem is when I press the button I do not get the data in that format (the url is localhost:1111/html_file.html? Any tips or links would be appreciated!

Your problem is that you are only looking at the URL (req.url) rather than looking at the body of the incoming message. When the request comes in via a GET request the query parameters are included in the URL. However, when the request is a POST (like when a user clicks the submit buttons in a form), the parameters are in the body of the request. That means you will need to do something like the example provided at http://nodejs.org/api/stream.html#stream_api_for_stream_consumers. Specifically, you will need to read the body and parse the parameters from that rather than parsing them from the URL (since they aren't in the URL).

Depending on what frameworks you are or aren't using, there may be easier ways to get this information.