Home > OS >  How to remove 'GET?' string from URL when submitting a GET form
How to remove 'GET?' string from URL when submitting a GET form

Time:02-05

I'm working on a search feature. When user enters a keyword, they should get a list of brands.

The current URL is http://127.0.0.1:8000/brand/list

If I search for "bag", it should be http://127.0.0.1:8000/brand/list?keyword=bag

But now, it's http://127.0.0.1:8000/brand/list/GET?keyword=bag. I wanna remove the GET? thing. How can I do this?

<section id="brand-list">
  <form action="GET">
    <input type="text" name="keyword">
    <button>Search</button>
  </form>
</section>

CodePudding user response:

You specified this as action="GET", this is the URL where the form will submit to, you should specify method="GET", or just nothing, since that is the default method, so:

<section id="brand-list">
  <form method="GET">
    <input type="text" name="keyword">
    <button>Search</button>
  </form>
 </section>
  •  Tags:  
  • Related