jquery/jquery-mobile — Issue #2836: Location header causes page transition without URL update
Author: aholmes
Created: 2011-10-25 17:11:03+00:00
State: open

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:

```
$('a:not(.video)')
.live('click', function(event)
{
var href = this.href, page = pageName_get(href);

event.preventDefault();

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

Summary:
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.