I am using node.js. It's a fairly simple file arrangement on a local server.
<h3>To Do!</h3>
<ol class="pending>
<li><a class="pending_task" href="localhost://nextstep.html">Task Three</a></li>
<li><a class="pending_task" href="localhost://nextstep.html">Task Five</a></li>
<li><a class="pending_task" href="localhost://nextstep.html">Task Six</a></li>
</ol>
and
<h3>Completed!</h3>
<ol class="completed">
<li><a class="completed_task" href="localhost://nextstep.html">Task One</a></li>
<li><a class="completed_task" href="localhost://nextstep.html">Task Two</a></li>
<li><a class="completed_task" href="localhost://nextstep.html">Task Four</a></li>
</ol>
Are lists on the same page. I finally have the ajax call working as desired, and now I am in the newest glitch.
The $.ajax redirects to the proper url and the connect is made, but there is no data when I do a console.log(req.data)
The AJAX call:
var newData = "<ol class=\"pending\">" + $('ol.pending').html() +
"</ol>" + "<ol class=\"completed\">" + $('ol.completed').html() + "<\ol>";
$.ajax({
method:'POST',
data: newData,
url: ajax_url,
success: function(result, status, jqxhr){
console.log("Response: " + jqxhr.responseText);
console.log("POST status: " + status);
},
dataType: 'html',
});
The app.js
http.createServer(function(req, res){
if ((req.method === 'POST') && (req.url === '/result')){
console.log("Request Data: " + req.data);
res.statusCode = 200;
res.end("Message Received!");
}
}).listen(port, serverURL);
My intended result is to rewrite the originating file with the new arrangement of completed/pending, after writing the old arrangement to a new file name (TODO_date_time.html), which I can't do yet because the generated data, passed to the AJAX call is not being transmitted. Or I am not accessing it preoperly.
What I get though is:
[nodemon] starting `node app.js`
Starting Web Server at local:4000
Request Data: undefined
The console.log in the browser is all good:
Not sure what's wrong with my work at this point.