yiisoft / jquery-pjax

pushState + ajax = pjax
http://pjax.herokuapp.com
MIT License
144 stars 40 forks source link

Pjax redirect not working in Internet Explorer (IE11). #26

Closed Q1WP closed 9 years ago

Q1WP commented 9 years ago

The controller code adds a header "X-Pjax-Url" that is successfully passed with the response.

The redirect for Pjax is handled through the pjax.js methods just fine in Chrome, Safari, and Firefox, but fails in IE11.

When I use the included IE debugger and view the response headers, the header is there and the url is correct, but IE11 isn't reading it.

The response error: pjax-response-error

The response headers: pjax-response-headers

Any ideas?

I have also asked this on the main Pjax GitHub page, but it hasn't received any responses.

SilverFire commented 9 years ago

Is the problem still alive?

flowip commented 9 years ago

@SilverFire, yes it is still alive. As a workaround I respond with 200 status for ajax redirects. Only because of IE.

SilverFire commented 9 years ago

@flowip we have two new options: pushRedirect and replaceRedirect. See for description here.

Could you try it, please?

flowip commented 9 years ago

@SilverFire, I don't use Pjax. I just respond with redirect to ajax request. Page redirects in all browsers except IE. I'm testting in IE11. I'm getting the following error in console: XMLHttpRequest: Network Error 0x2f76, Could not complete the operation due to error 00002f76.. URL for redirect sent in X-Redirect header. yii.js script handles this header, see line 265. var url = xhr.getResponseHeader('X-Redirect');. In case of IE11 getResponseHeader() returns null instead of URL. As I mentioned before I just respond with 200 status at the moment instead of 302.

SilverFire commented 9 years ago

Oh, I got it. Then it's better to move this issue to the main repo https://github.com/yiisoft/yii2 as it does not affect Pjax plugin itself.

flowip commented 9 years ago

@SilverFire, It was there: https://github.com/yiisoft/yii2/issues/9670. I don't really think it's Pjax bug. I think it's a bug in Yii ajax redirect mechanism. I may be wrong, because I don't use Pjax.

samdark commented 9 years ago

Closing it here then.

nepster-web commented 8 years ago

I use redirect 308:

    public function redirect($url, $statusCode = 302, $checkAjax = true)
    {
        if (Yii::$app->getRequest()->getIsAjax()) {
            if ($statusCode == 302) {
                $statusCode = 308;
            }
        }
        return parent::redirect($url, $statusCode, $checkAjax);
    }