Bug Tracker

Modify

Ticket #5097 (closed bug: worksforme)

Opened 4 years ago

Last modified 2 years ago

getJSON break FF history

Reported by: monstroplante Owned by:
Priority: low Milestone:
Component: ajax Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 3 years ago by dmethvin

  • Component changed from unfiled to ajax

comment:2 Changed 3 years ago by addyosmani

#5044 is a duplicate of this ticket.

comment:3 Changed 3 years ago by rwaldron

  • Priority changed from major to low
  • Status changed from new to open
  • Version changed from 1.3.2 to 1.4.3
  • Milestone 1.4 deleted

Confirmed.

 http://jsbin.com/uboce

(wont work correctly on jsfiddle)

comment:4 Changed 3 years ago by rwaldron

  • Milestone set to 1.5

comment:5 Changed 3 years ago by snover

  • Milestone 1.5 deleted

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 2 years ago by dmethvin

  • Status changed from open to closed
  • Resolution set to worksforme

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.