开发者

handling http 302 redirect in nyroModal

I'm using nyroModal v2 in an ASP.NET MVC3 application. The application forces users to authenticate and the auth cookie has max. lifetime of two hours. When the auth cookie expires all requestes are redirected to a login page (using http status code 302).

When a user opens a link in a modal "window" (using jQuery plugin nyroModal) and the auth cookie is expired nyroModal shows "an error has occoured". I managed to add a callback function to handle all errors

 $(this).nyroModal({                
            callbacks: {                   
                error: function (nm) {
                    alert("some error");
              开发者_StackOverflow中文版  }                
        });

but I don't see a way to decide what kind of error (http status code) has happened. Is there an error object in nyroModal?

What I want to achieve is: close the modal window and redirect the browser window to the login page.

Thanks in advance!

Thomas


$(window).ajaxComplete(function(ev, xmlhr, options){
try {
var json = $.parseJSON(xmlhr.responseText);
}
catch(e) {
console.log('Session OK');
return;
}
if ($.isPlainObject(json) && json.SESSION == 'EXPIRED') {
console.log('Session Expired');
return;
}
console.log('Session OK');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜