开发者

how to add method i.e get/post in a form using jquery

开发者 https://www.devze.com 2023-04-07 07:01 出处:网络
I am us开发者_高级运维ing spring mvc in my project. <form:form method=\"\" action=\"\"id=\"myform\" commandName=\"users\">

I am us开发者_高级运维ing spring mvc in my project.

 <form:form method="" action=""  id="myform" commandName="users">

I have this form, want to add action a runtime using 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:

$('#myform').attr('action','changePWD').attr('method','POST');

Why would you not do it with Javascript though if that is working fine as you say?


$('#myform').attr({
    action: 'changePWD',
    method: 'POST'
});

But I agree with Kokos, why fix what's not broken?

0

精彩评论

暂无评论...
验证码 换一张
取 消