Skip to content

Commit d13d1a5

Browse files
committed
Cancel pending XHR when back/forward clicked
1 parent 9d10182 commit d13d1a5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

jquery.pjax.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,14 @@ if ('state' in window.history) {
408408
// You probably shouldn't use pjax on pages with other pushState
409409
// stuff yet.
410410
function onPjaxPopstate(event) {
411+
412+
// Cancel the current request if we're already pjaxing
413+
var xhr = pjax.xhr
414+
if ( xhr && xhr.readyState < 4) {
415+
xhr.onreadystatechange = $.noop
416+
xhr.abort()
417+
}
418+
411419
var state = event.state
412420

413421
if (state && state.container) {

0 commit comments

Comments
 (0)