Naja and do parameter in URL
- Ajax
- Member | 59
Hello everyone!
I don't know what I do wrong. I used https://github.com/jiripudil/Naja
for ajax. Ajax work as expected, url is changed as expected, but the problem is
naja adds ?do=
param into url. Is there some configuration or is it
default behavior?
Thanks for answers!
- jiri.pudil
- Nette Blogger | 1032
Hello @Ajax,
the do
parameter is indeed added by Nette, regardless of whether
the request is asynchronous or not. The thing is that with synchronous requests,
you usually redirect to the canonical URL (without the do
parameter). With async request, you need to give Naja a hint as to what the
canonical URL should be; please see the related docs.
(The parameter is seemingly not added in nette.ajax.js because it does not manipulate the browser history – that's something done by a separate extension. Naja, on the other hand, does include the behaviour of the aforementioned extension by default.)
- Ajax
- Member | 59
jiri.pudil wrote:
Hello @Ajax,
the
do
parameter is indeed added by Nette, regardless of whether the request is asynchronous or not. The thing is that with synchronous requests, you usually redirect to the canonical URL (without thedo
parameter). With async request, you need to give Naja a hint as to what the canonical URL should be; please see the related docs.(The parameter is seemingly not added in nette.ajax.js because it does not manipulate the browser history – that's something done by a separate extension. Naja, on the other hand, does include the behaviour of the aforementioned extension by default.)
Great! Thanks! :)