Skip to content

Commit 520f8c1

Browse files
committed
Merge pull request #5 from tof06/pjax-fix-redirect
Let PJAX request follows HTTP Redirect in any case
2 parents 7433000 + c019c57 commit 520f8c1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

jquery.pjax.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,11 @@
231231

232232
options.error = function (xhr, textStatus, errorThrown) {
233233
var container = extractContainer("", xhr, options)
234-
235-
var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options])
236-
if (options.type == 'GET' && textStatus !== 'abort' && allowed) {
234+
// Check redirect status code
235+
var redirect = (xhr.status >= 301 && xhr.status <= 303)
236+
// Do not fire pjax::error in case of redirect
237+
var allowed = redirect || fire('pjax:error', [xhr, textStatus, errorThrown, options])
238+
if (redirect || (options.type == 'GET' && textStatus !== 'abort' && allowed)) {
237239
locationReplace(container.url)
238240
}
239241
}
@@ -342,7 +344,7 @@
342344
}
343345

344346
// Strip _pjax parameter from URL, if exists.
345-
options.url=stripPjaxParam(options.url);
347+
options.url = stripPjaxParam(options.url);
346348

347349
pjax.options = options
348350
var xhr = pjax.xhr = $.ajax(options)

0 commit comments

Comments
 (0)