Opened 13 years ago
Closed 12 years ago
#5097 closed bug (worksforme)
getJSON break FF history
Reported by: | monstroplante | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | ajax | Version: | 1.4.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If i redirect on the callback of getJSON and then use the back button on the browser, the displayed page is not the exepted one. (tested on FF3.5).
Here is a test code :
<a class="btTest">Test</a> <script type="text/javascript"> $('.btTest').click(function() { $.getJSON('http://maps.google.com/maps/geo?callback=?', function() { window.location = 'http://google.fr'; }); }); </script>
I found a hack :
Handle JSONP-style loading window[ jsonp ] = function(tmp){setTimeout(function() {
data = tmp; success(); complete(); Garbage collect window[ jsonp ] = undefined; try{ delete window[ jsonp ]; } catch(e){} if ( head )
head.removeChild( script );
}, 1);};
Change History (6)
comment:1 Changed 13 years ago by
Component: | unfiled → ajax |
---|
comment:2 Changed 12 years ago by
comment:3 Changed 12 years ago by
Milestone: | 1.4 |
---|---|
Priority: | major → low |
Status: | new → open |
Version: | 1.3.2 → 1.4.3 |
comment:4 Changed 12 years ago by
Milestone: | → 1.5 |
---|
comment:5 Changed 12 years ago by
Milestone: | 1.5 |
---|
When a script loads and immediately redirects the page, Firefox pretends that it like the server performed a 3xx direct and removes the previous page from the browser history. This has nothing to do with jQuery.
broken works, using onload works, using setTimeout
This does not happen if the assignment to window.location happens from the script’s onload
method, or if it is deferred using setTimeout
.
Workaround: Do not modify the location of the window using window.location in response to a JSONP call without wrapping it in setTimeout
.
comment:6 Changed 12 years ago by
Resolution: | → worksforme |
---|---|
Status: | open → closed |
#5044 is a duplicate of this ticket.