From c019c57bde7663a39ad7ba9082f7d330a78432c9 Mon Sep 17 00:00:00 2001 From: Christophe BOULAIN Date: Thu, 20 Mar 2014 12:22:18 +0100 Subject: [PATCH] Let PJAX request follows HTTP Redirect in any case --- jquery.pjax.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jquery.pjax.js b/jquery.pjax.js index b9ea7f22..1e090d70 100644 --- a/jquery.pjax.js +++ b/jquery.pjax.js @@ -231,9 +231,11 @@ options.error = function (xhr, textStatus, errorThrown) { var container = extractContainer("", xhr, options) - - var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options]) - if (options.type == 'GET' && textStatus !== 'abort' && allowed) { + // Check redirect status code + var redirect = (xhr.status >= 301 && xhr.status <= 303) + // Do not fire pjax::error in case of redirect + var allowed = redirect || fire('pjax:error', [xhr, textStatus, errorThrown, options]) + if (redirect || (options.type == 'GET' && textStatus !== 'abort' && allowed)) { locationReplace(container.url) } } @@ -342,7 +344,7 @@ } // Strip _pjax parameter from URL, if exists. - options.url=stripPjaxParam(options.url); + options.url = stripPjaxParam(options.url); pjax.options = options var xhr = pjax.xhr = $.ajax(options)