Skip to main content

Bug Tracker

Side navigation

#5097 closed bug (worksforme)

Opened August 24, 2009 02:22PM UTC

Closed December 24, 2010 02:53AM UTC

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);};

Attachments (0)
Change History (6)

Changed June 13, 2010 05:01PM UTC by dmethvin comment:1

component: unfiledajax

Changed October 26, 2010 06:09PM UTC by addyosmani comment:2

#5044 is a duplicate of this ticket.

Changed October 26, 2010 10:49PM UTC by rwaldron comment:3

milestone: 1.4
priority: majorlow
status: newopen
version: 1.3.21.4.3

Confirmed.

http://jsbin.com/uboce

(wont work correctly on jsfiddle)

Changed October 26, 2010 10:52PM UTC by rwaldron comment:4

milestone: → 1.5

Changed October 26, 2010 11:47PM UTC by snover comment:5

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.

Changed December 24, 2010 02:53AM UTC by dmethvin comment:6

resolution: → worksforme
status: openclosed