I have a web application that posts a form to a Node.js webservice:
...method="post" action="/kudosapi/report"...
Now I need to implement an auto-save feature on this form. I can work out how to detect changes, etc., but what I'm not sure about is how (or IF) I can leverage this same HTML form action.
In the current design, once the user clicks a [Save] button, the form is submitted and the Node.js service redirects them back to another, i.e., the main, screen (this page is an editor).
My first instinct was to pass a parameter in the form to let the service know that's being auto-saved so it would not do the re-direct but I'm not sure that's sufficient.
Suggestions now how I can do this w/o completely rewriting the form/API?
Thanks!
What you need to know in this case is that there is a difference in how you can POST data from the client: you can do it synchronously or asynchronously. Sending a POST in an asynchronous way is what you want to do here, and you can do that with an ajax request the likes of:
$.ajax( {
method : "POST" ,
url : "/kudosapi/report" ,
[ .. ]
} );