PJAX's documentation states that Github uses $.pjax.submit()
in submitting a Gist form. A desired feature of an ajax form submission which Github nicely implements is that the URL redirects from the form's action
to a newly created URL (in this case, one containing the newly server-side created gist ID).
For example, from this:
https://gist.github.com/gists // form action
to this:
https://gist.github.com/tim-peterson/5019589 //assume this ID is generated server side
I've gotten this to work similarly on my site (i.e., the page itself redirects to the equivalent of https://gist.github.com/tim-peterson/5019589) but I can't redirect the URL (it stays like https://gist.github.com/gists).
Is this entirely a server-side issue (setting headers?) or is there something in pjax that I'm missing? I'm using a version of pjax I downloaded today so it can't be that i'm using a buggier version of pjax.
data.url
was pushed to the browser bar just like the content was pushed to#main-content
. Now that I'm looking at it, Github Gist appears to be doing the same thing as us in making 2 requests though they are doing PJAX(POST)->PJAX(GET) and we are doing AJAX(POST)->PJAX(GET). The bottom line is that it would seem more performant to do only 1 request (continued in next comment...). – Epifaniaepifano