开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜