There are 3 components to my problem.
- Declaring a server side (node.js) variable to hold data for the duration of the server run - just a number.
- Sending a number to the server from the client (jQuery) to update the server value.
- Sending a number back to the client as calculated by the server from the new number.
I haven't been successful creating a variable I can access - I have tried a separate .js file with export.global
, as well as var sum = require('./sum');
My best guess to send the data to the server is $.post ('/sum', 'entry=20', showNewTotal);
.
I can also get it on to the HTML display in showNewTotal $('#currentSum').text('data');
This seems like it should be simple, however I haven't been able to identify any examples.