Chome is used for simplicity. I am curious about Firefox as well
In a non-AJAX form, when a user enters data into a field with a name, then that data will be remembered in the future when they want to put data into that field again.
So, if I have this:
<h1>Normal Form</h1>
<form id="normalForm" action="/api/submitData" method="POST">
<input name="willAutofillInTheFutureNormal" type="text" />
<input type="submit" value="Submit" />
</form>
Then when the Submit
button is clicked, then Chrome will POST the data to the backend, and when the user visits the page again, if they click in the field, then their previous entries will be shown.
But, if I add this code
$("#form").submit(e => {
e.preventDefault();
const data = {
data: document.getElementsByName("willAutofillInTheFuture")[0].value
};
$.post("/api/submitData", JSON.stringify({ data: data }));
});
Now Chrome doesn't save the inputs anymore.
You can try this out here. JSFiddle
Note: You'll need to re-run when using the normal form to re-load the page and see the auto-complete.
I've tried changing the action
URI, and setting the form to have display:none
as suggested in Getting Chrome to prompt to save password when using AJAX to login, but that didn't work individually or combined.