Forms with GET method not working #126

Closed
opened 2018-02-18 15:23:39 -05:00 by Sevenarth · 4 comments
Sevenarth commented 2018-02-18 15:23:39 -05:00 (Migrated from github.com)

Hi,
I am using your fantastic module for my new application but I encountered a problem with forms.
I figured it is working perfectly for forms with POST method, but when I try to use GET form, the form submits without appending the fields to the query string. The form in specific is a search form, with a singular field named s. I checked the web inspector and the module is making a successful GET request to the URL in action but it is not appending the query string.

Cheers,
Luca

Hi, I am using your fantastic module for my new application but I encountered a problem with forms. I figured it is working perfectly for forms with POST method, but when I try to use GET form, the form submits without appending the fields to the query string. The form in specific is a search form, with a singular field named **s**. I checked the web inspector and the module is making a successful GET request to the URL in **action** but it is not appending the query string. Cheers, Luca
robinnorth commented 2018-02-19 04:27:35 -05:00 (Migrated from github.com)

Can you post your code or ideally make a reduced test case using JSFiddle that demonstrates the issue?

Can you post your code or ideally make a reduced test case using JSFiddle that demonstrates the issue?
Sevenarth commented 2018-02-19 13:22:43 -05:00 (Migrated from github.com)

Thank you for your answer, apparently JSFiddle does not accept forms with GET request. I will just write my code down here.

JS/Webpack

var Pjax = require('pjax')

var pjax = new Pjax({
  selectors: ["title", "main", "#header-nav"],
  cacheBust: false
})

HTML/Blade (Laravel)

<form action="{{ route("panel.sellers.home") }}" method="get">
  <div class="row">
    <div class="input-group mb-3 col-sm-6">
        <input type="text" name="s" value="{{ Request::query("s") }}" class="form-control" placeholder="Name, email address, ID...">
        <div class="input-group-append">
          <button class="btn btn-outline-secondary" type="submit">
            <i class="fa fa-fw fa-search"></i>
          </button>
        </div>
    </div>
  </div>
</form>

If there is anything else needed just ask. I tried removing the Pjax snippet, and the form works just fine, append the query string to the URL as supposed to do. The HTML section of the code is inside the selector main, indeed Pjax works as it correctly submits the form using GET as method, but as said above it does not append the query string to the URL.

Thank you for your answer, apparently JSFiddle does not accept forms with GET request. I will just write my code down here. JS/Webpack var Pjax = require('pjax') var pjax = new Pjax({ selectors: ["title", "main", "#header-nav"], cacheBust: false }) HTML/Blade (Laravel) <form action="{{ route("panel.sellers.home") }}" method="get"> <div class="row"> <div class="input-group mb-3 col-sm-6"> <input type="text" name="s" value="{{ Request::query("s") }}" class="form-control" placeholder="Name, email address, ID..."> <div class="input-group-append"> <button class="btn btn-outline-secondary" type="submit"> <i class="fa fa-fw fa-search"></i> </button> </div> </div> </div> </form> If there is anything else needed just ask. I tried removing the Pjax snippet, and the form works just fine, append the query string to the URL as supposed to do. The HTML section of the code is inside the selector **main**, indeed Pjax works as it correctly submits the form using GET as method, but as said above it does not append the query string to the URL.
robinnorth commented 2018-02-21 13:35:48 -05:00 (Migrated from github.com)

Thanks @Sevenarth, you are quite right that Pjax wasn't appending the query string to the URL when submitting GET forms. This should be fixed in #129 now.

If you have time, perhaps you could check out the branch and test this for me?

Thanks @Sevenarth, you are quite right that Pjax wasn't appending the query string to the URL when submitting GET forms. This should be fixed in #129 now. If you have time, perhaps you could check out the branch and test this for me?
robinnorth commented 2018-03-02 15:25:44 -05:00 (Migrated from github.com)

Fixed in #129

Fixed in #129
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#126