Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ronon's avatar
Level 9

JS generated url not working. Same url typed in manually works.

I'm trying to implement a perPage functionality to a site. I have different dropdown boxes where the user can choose the order, perPage and some other values. If he clicks submit i generate an url with the given values and redirect the user with location.href (Form not really possible since i'm using https://vuetifyjs.com/releases/0.15/ ).

If i redirect the user now to a js generated url like: http://127.0.0.1:8000/products?perPage=54&orderBy=asc&order=title i receive and 302 redirect.

But if I enter the same url manually in the address bar: http://127.0.0.1:8000/products?order=asc&orderBy=title&perPage=54 it works.

dd() output called with js:

array:3 [▼
  "perPage" => "54"
  "orderBy" => "asc"
  "order" => "title"
]

dd() output entered manually in address bar:

array:3 [▼
  "order" => "asc"
  "orderBy" => "title"
  "perPage" => "54"
]

rule:

return [
            'perPage' => 'nullable|numeric',
            'orderBy' => ['nullable', Rule::in($this->orderBy)],
            'order' => ['nullable', Rule::in($this->order)]
        ];

I also tried to remove/change the perPage key, but with no effect.

Why the heck is the js generated url not working but the manually one does?

It's driving me crazy. It looks exactly the same and it's working if entered manually :(

0 likes
2 replies
ronon's avatar
Level 9

Weird that part was working O.o The perPage part wasn't working. I rewrote the numbers and now it's working. Weird bug.

But thanks for the hint. I was fixed on the perPage part so i didn't took a look at the order and orderBy parameters.

Please or to participate in this conversation.