lundi 9 février 2015

How can I send the client data, along with a served Html page?

I'm building a basic web app.


I'm serving the client an Html page that references some .js files. The attached script needs to manipulate the DOM according to some data (e.g., a username). This data is stored in the server.


The client can either request the data from the server, which seems odd since data (an Html file) just arrived from the server, or it can receive the data along with the served file.


So in Node.js and Express, how can I send the client data along with the served file? Is the query-string the best option? If so, how do I create a query string to send along with the page? If not, what are the other options?


Also, is the option of the client-script simply requesting the information from the server a common approach? It seems odd but it is okay?





Aucun commentaire:

Enregistrer un commentaire