mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1219] Would an AJAX endpoint/callback be useful? #1039
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1039
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JasXSL on GitHub (Feb 28, 2021).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1219
Was about to make a pull request, but saw you wanted it discussed in an issue first
In our project we use WiFiManager for configuring our device with a random token generated by the ESP. As such we've added a button to the front page that makes an AJAX request to generate a new token, and return this token to be presented to the user. In my fork I added a pretty basic handler that allows you to make requests to
/ajaxand bind a callback to return a String which is sent as the response. If no callback exists, it returns an empty string.Example:
Bind a callback before starting the portal:
wifiManager.setAjaxCallback(std::bind(&VhWifi::onAjax, this, _1));Handle the callback:
Example of JS injected through
setCustomHeadElement:Should I make a pull request for this, or would you consider this bloat?
@OldGreyCells commented on GitHub (Mar 1, 2021):
I'm probably well out of line here, but I like the *nix library concept of doing one thing well. To that end, would it be possible for WiFiManager to 'plugin' a webserver class/interface that allows the use of other webserver libraries? eg websockets via ESPAsyncTCP [https://github.com/me-no-dev/ESPAsyncTCP]? I'm currently planning to use that library for app config (and for async MQTT) which means I will have two webserver libraries installed.
Feel free to shout at me!