简体   繁体   English

表单提交附加URL

[英]Form Submit appends URL

i want to submit an form using Jquery.But my form Url appends with existing URL and submitting the form with the appended URL. 我想使用Jquery提交表单,但是我的表单Url追加了现有的URL,并提交了带有追加URL的表单。

Before Submit : 提交之前:

URL on Browser : localhost:8000/view/items 浏览器上的URL: localhost:8000/view/items

HTML: HTML:

     <form action="edit/items" method="post" id="editform">
            <input type="hidden" id="itemID" value="blahblah">
            <a href="#" id="editItem">Edit</a>
        </form>

JQuery: jQuery的:

$("#editProperty").click(function(e){
    $("#editPropertyForm").submit();
});

After Form Submit I get ie URL goes as : localhost:8000/view/items/edit/items 提交表单后,我得到的URL即为: localhost:8000/view/items/edit/items

How do i solve it ? 我该如何解决?

The problem is that your form's action is a relative path. 问题在于表单的动作是相对路径。 I think what you want is "/edit/items" . 我认为您想要的是"/edit/items" That'll take the root path and add edit/items to it. 这将采用根路径并向其中添加编辑/项目。

将表单操作从相对URL更改为绝对URL,即:

<form action="/edit/items" method="post" id="editform">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM