onSubmit method
See original GitHub issueI implemented the onSubmit method, these are the two methods that can be used, what do they think of implementing the project?
onSubmitXHR: function(cmd, url, record) {
var xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
return JSON.parse(xhr.responseText);
}
};
xhr.send(JSON.stringify({ cmd: cmd, record }));
},
onSubmit: function(cmd, url, record) {
(async () => {
const rawResponse = await fetch(url, {
method: "POST",
credentials: "include",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify({ cmd: cmd, record })
}).catch(function(error) {
console.log("Request failed", error);
});
const content = await rawResponse.json();
})();
},
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
onsubmit Event - W3Schools
onsubmit Event ... Definition and Usage. The onsubmit event occurs when a form is submitted. ... In JavaScript, using the addEventListener() method: object....
Read more >How onsubmit Event work in JavaScript? Examples - eduCBA
The onsubmit event is performed the triggers is based upon the submit function whenever the client user request in the form-wise data is...
Read more >HTMLFormElement: submit event - Web APIs | MDN
The submit event fires when the user clicks a submit button ( <button> or <input type="submit">) or presses Enter while editing a field...
Read more >HTML form action and onsubmit issues - Stack Overflow
The problem I'm having is that my form has the action of going to a new page within our site, and the onsubmit...
Read more >JavaScript Onsubmit Event with form validation - FormGet
This blog emphasize to JavaScript onsubmit event in which a function is called when form is submitted to validate the fields and if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pmk65, As I see it, perfect, I have tested here and perfect, even can be added the method onSubmit with simplicity. Great job!
Should we close this, as the changes is now available in https://github.com/json-editor/json-editor/tree/develop/2.x