Created
April 15, 2022 11:45
-
-
Save Guidosalimbeni/0637c362116261784f718603faa16451 to your computer and use it in GitHub Desktop.
Submit to PHP connection to MySQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let question = "test question'; | |
let answer = 'test answer'; | |
let form = new FormData(); | |
form.append("question", question); | |
form.append("answer", answer); | |
fetch("http://www.guidosalimbeni.it/-- xxx xxx xxx --- .php", { | |
// URL | |
// body: JSON.stringify(form), // data you send. | |
body: new URLSearchParams(form), | |
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached | |
headers: { | |
"content-type": "application/json", | |
}, | |
method: "POST", // *GET, POST, PUT, DELETE, etc. | |
mode: "no-cors", // no-cors, cors, *same-origin | |
redirect: "follow", // *manual, follow, error | |
referrer: "no-referrer", // *client, no-referrer | |
}) | |
.then((resp) => { | |
console.log(resp); | |
}) | |
.then((err) => console.log(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment