How to handle an HTTP POST using MVC onchange of an input[“text”]
-
23-08-2019 - |
Question
I'm looking for a good example that shows how to handle (in the controller) a POST onchange (of a input["text"] for example)
Currently when I set my onchange = form[0].submit(); and I watch the action hit the controller, the HTTP verb is still GET for some odd reason. But when I view source the form on the page has the method="POST" ... so what am I doing wrong?
Solution
Are you able to make use of an ajax library (jquery, ms, whatever) and set up a post for the call instead?
"The javascript submit() method does not fire the onsubmit event, but bypasses it and directly submits the form. " - http://www.webmasterworld.com/forum91/4047.htm
OTHER TIPS
you should put
return false
at the end of submit event handler function
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow