Naja and do parameter in URL

14 days ago

Ajax
Member | 57
+
0
-

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!

14 days ago

Ondřej Kubíček
Member | 359
+
0
-

do adds nette itself, it is default behavior

13 days ago

Ajax
Member | 57
+
0
-

But not during ajax.. I mean when I use jQuery version of nette.ajax.js, do parameter is not added..

13 days ago

jiri.pudil
Member | 836
+
+1
-

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.)

13 days ago

Ajax
Member | 57
+
0
-

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 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.)

Great! Thanks! :)