[英]how to add method i.e get/post in a form using jquery
I am using spring mvc in my project. 我在项目中使用spring mvc。
<form:form method="" action="" id="myform" commandName="users">
I have this form, want to add action a runtime using jquery. 我有这种形式,想使用jquery在运行时添加动作。 how can I do it Using javascript I was doing as which worked fine
我该怎么做呢?
document.getElementById("myform").action = "changePWD"
document.getElementById("myform").method="POST";
Using jQuery: 使用jQuery:
$('#myform').attr('action','changePWD').attr('method','POST');
Why would you not do it with Javascript though if that is working fine as you say? 如果您说的很好,为什么不使用Javascript呢?
$('#myform').attr({
action: 'changePWD',
method: 'POST'
});
But I agree with Kokos, why fix what's not broken? 但是我同意Kokos,为什么要修复未损坏的内容?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.