admin管理员组

文章数量:1401241

i want to submit an form using Jquery.But my form Url appends with existing URL and submitting the form with the appended URL.

Before Submit :

URL on Browser : localhost:8000/view/items

HTML:

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

JQuery:

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

After Form Submit I get i.e URL goes as : localhost:8000/view/items/edit/items

How do i solve it ?

i want to submit an form using Jquery.But my form Url appends with existing URL and submitting the form with the appended URL.

Before Submit :

URL on Browser : localhost:8000/view/items

HTML:

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

JQuery:

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

After Form Submit I get i.e URL goes as : localhost:8000/view/items/edit/items

How do i solve it ?

Share Improve this question asked Nov 11, 2014 at 18:19 user3383301user3383301 1,9313 gold badges22 silver badges49 bronze badges 1
  • 2 Your action is a relative URL, which means it must append to the current URL. Put a forward slash before the edit. – Mike Commented Nov 11, 2014 at 18:22
Add a ment  | 

2 Answers 2

Reset to default 6

The problem is that your form's action is a relative path. I think what you want is "/edit/items". That'll take the root path and add edit/items to it.

Change your form action from a relative to an absolute URL, i.e.:

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

本文标签: javascriptForm Submit appends URLStack Overflow