Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example of dynamic web page with input and output #28

Open
ghislainborremans opened this issue Oct 5, 2017 · 10 comments
Open

example of dynamic web page with input and output #28

ghislainborremans opened this issue Oct 5, 2017 · 10 comments
Labels

Comments

@ghislainborremans
Copy link

Hello

i keep fighting with this.
Is it possible to include an example of a dynamic webpage with the coding to put the data on that page.
I want to enter 2 values (calibration) and to show the temperature of 2 sensors in 1 page.
It should be simple but i am not getting there.

Any help would be aprreciated;

@species5618
Copy link
Collaborator

It the one exmaple i have not had time to get to

i know how i want to do it, i will get to it soon

@species5618
Copy link
Collaborator

call back example now include miniajax get and form post example for dynamic user content

updated data folder to include user.html example

also added ability to store user config values in SPIFFs in userconfig.json file

sample code
ESPHTTPServer.save_user_config("Test", "Test");
String T = "";
ESPHTTPServer.load_user_config("Test", T);
Serial.print("S: ");
Serial.println(T);

		//ESPHTTPServer.save_user_config("TestI", 10);
		int I = 0;
		ESPHTTPServer.load_user_config("TestI", I);
		Serial.print("I: ");
		Serial.println(I);

		//ESPHTTPServer.save_user_config("TestF", 10);
		float F = 0.0;
		ESPHTTPServer.load_user_config("TestF", F);
		Serial.print("F: ");
		Serial.println(F);

@species5618
Copy link
Collaborator

callback example updated to save the data in the SPIFFS userconfig.json file

@gmag11 gmag11 added the question label Oct 8, 2017
@gmag11
Copy link
Owner

gmag11 commented Oct 8, 2017

Several pages on the project show how this is done. You can find it on https://github.com/gmag11/FSBrowser/blob/master/DynamicData.cpp file. It uses a simple implementation of AJAX.

@ghislainborremans
Copy link
Author

thank you. I will try it when i am back and return some feedback..

@mancior
Copy link

mancior commented Oct 11, 2017

Hello
This is really great project! Thank You for it.
There are samples of callback with POST and REST. Please give some with JSON, please.

I have json structure {"items":[{"addr":"10380865","name":"test1"},{"addr":"1415368","name":"test2"},{"addr":"5672520","name":"test3"}]} which I got after using
console.log('currentData to write:' , JSON.stringify(currentData));
But how to write it to file and how to read it again from that file? Thank You in advance.

@ghislainborremans
Copy link
Author

Hello
I have been able to use the "callback" example. this is very nice.
However i do not understand that each time both the REST and Post callback are executed.
is this normal? and if so why ?

@species5618
Copy link
Collaborator

no, each callback should only go off once if the folder relevant folder is called
i cant see anything obvious in the code
i dont have access to hardware for a few days i will check at the weekend

@species5618
Copy link
Collaborator

can ask how you discovered /think this is the case

@species5618
Copy link
Collaborator

sorry just re reading you question

the form example, will use REST to read the data on page load
and then when you click save will "post" to save the data
and then refreshes, so will call call REST to get the new data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants