简体   繁体   English

如何添加方法,即使用jQuery以表格形式获取/发布

[英]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.

相关问题 如何在使用“全选”运算符(即“ *”)和jquery时获得点击元素? - how to get clicked element while using “select all” operator i.e “ * ” using jquery? element.setAttibute()方法如何使其在IE中工作? - element.setAttibute() method how to make it work in I.E? 预期为“;” IE中的异常(JavaScript,jQuery) - Expected ';' exception in I.E (JavaScript, jQuery) Firefox和IE中的Jquery问题,但Chrome中没有 - Jquery issue in Firefox and I.e but not Chrome 如果我们要先执行javascript,然后执行php post方法(即提交),该怎么办 - what to do if we want javascript to be executed first then the php post method i.e submitting 如何在jquery中使用get方法提交表单 - how do i submit a form using get method in jquery 我想使用用户脚本在tinymce编辑器中捕获键盘事件(即添加键盘快捷键) - I want to capture keyboard events in tinymce editor using a userscript (i.e add keyboard shortcuts) 如何通过javascript提交的php curl登录,即表单中没有提交按钮 - how to login through php curl which is submited by javascript i.e no submit button in form 如何在 mysql 从表单提交时存储图像名称/值(即与单选按钮相同) - How to store image name/value on submit in mysql from a form (i.e same as radio button) jQuery:如何覆盖特定元素的默认方法(即html,append)? - jQuery: how to override default methods (i.e html, append) for particular element?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM