Location header causes page transition without URL update #2836

aholmes opened this Issue Oct 25, 2011 · 7 comments


None yet

6 participants

aholmes commented Oct 25, 2011

We have a framework that, when a user logs in, a Location header is passed back from PHP.

It appears that JQM is picking up on this header and causing a page transition to the POST URL, while loading the content at the redirected location. This is an issue when, for example, the page is refreshed and the browser attempts to access the wrong resource.

We have a few javascript functions bound to pageinit and pageshow. The page will resize a few elements, initialize a carousel, or inject video, but we are not messing with the internals of JQM.

We are also (but I do not suspect this is related) processing most hyperlinks with the following code:

    .live('click', function(event)
        var href = this.href, page = pageName_get(href);


        // if the page is still loading, don't allow more clicks. each page preloads,
        // and it would cause each clicked page to load in succession after the previous page finished loading
        if (page_load.loading) return false;

        $.mobile.changePage(page, {
            allowSamePageTransition : false,
            changeHash  : true,
            reloadPage  : false,
            reverse     : false,
            showLoadMsg : true,
            transition  : 'slide',
            type        : 'get'

Of further note, we only create one div (in the initial document) with data-role="page" while each successive page is pulled in via ajax.

User logs in and POSTs to "/member/post."
Browser receives "Location: /" header.
JQM AJAX loads "/" and does a page transition, but URL is not updated in browser.
User hits refresh and "/member/post" is accessed via GET.

Browser: Google Chrome 15.0.874.102 beta
OS:        Darwin 10.8.0

Browser: Native
OS:        Android 2.3.4
Device:   DROID3
Build:      5.5.1_84_D3G-55

JQM:      1.0-rc2

We'll have to take a look, but is that a way to post a jsbin that illustrates this? Seems tricky to make a test page in this situation. In the meantime, did you read through all the Ajax nav details here, might give you some hints:

aholmes commented Jan 14, 2012

Apologies for the months-long delay. Please view an example here: http://www.aaronholmes.net/jqm/

The "post it" button submits to /jqm/post.php, which sends a "Location: /jqm/" header.

The content is loaded correctly, but the URL contains "/jqm/post.php"

For your reference: http://jsbin.com/ajohac/5
Note that jsbin is making a post to a different domain, and so everything behaves at expected.

Of interesting note, if the form action is "http://aaronholmes.net/jqm/post.php" instead of "/jqm/post.php," JQM behaves as expected as well.

Edit: scratch my last sentence, wasn't paying attention to the "www." part of my domain.


+1. Using Symfony 2.1 framework, I have a stackoverflow question about it too: http://stackoverflow.com/questions/12516902/symfony-2-and-jquery-mobile-1-1-1


Workaround found: If data-ajax is false, it works like charm, although ajax is not used (of course).

<form method="post" action="/logincheck" data-ajax="false">

solves the problem.

ldeluca commented Oct 22, 2014

Hey @gergelypolonkai @aholmes There hasn't been any updates to this issue in over 2 years. Can you confirm if it's still an issue with the latest jQM version or if this can be closed? Thanks

aholmes commented Oct 22, 2014

I have not used jQM in the same amount of time, so am unable to confirm if this is still an issue.


@aholmes thank you for responding so quickly. I think ill close this for now then but if any one can still reproduce just comment and we will re open.

@arschmitz arschmitz closed this Oct 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment