EasyUI Forum

General Category => General Discussion => Topic started by: mzeddd on August 16, 2012, 08:10:09 AM



Title: Reload whole page while loading data into TAB(smth happened, we have to do this)
Post by: mzeddd on August 16, 2012, 08:10:09 AM
Hi,

There is a question.

For example I'm opening some page with TABs, fill in the form and press "next" to open new TAB with lets call it "results" and load content generated by my script (lets call it "script.php")
Due to some things on server (ex. session has expired) I have to reload the page completely.

I tried to call "header('Location: http://myhost');" PHP function in my script.php but it reload "http://myhost" inside my new "results" TAB.

How can I do what I wanted to have?

Thanks


Title: Re: Reload whole page while loading data into TAB(smth happened, we have to do this)
Post by: anton.dutov on August 16, 2012, 05:59:03 PM
If tabs loads by ajax try that
 
when session expires you would send code 403 Unauthorized (in script.php)

Globaly set:
Code:
$(function(){
 
  $.ajaxSetup({
    statusCode: {
      403: function() { location.assign('/auth/'); }
    }
  });

});
if ajax response returns 403 then javascript code redirect from curret page to page 'http://myhost.com/auth/'
or change location.assign('/auth/'); to location.assign('/'); to redirect to site root

Also i not recommend use redirect in scripts wich generates ajax content, some browsers follows redirect and loads content from there.
(like in you case)
By example

Without redirect

ajax.get('/somepage/')
  -> GET /somepage/ <- 200 OK, Content, Return content /somepage/


ajax.get('/somepage/')
  -> GET /somepage/ <- 302 Moved temprary, Location: /otherpage/ 
  -> GET /otherpage/ <- 200 OK, Content, Return content /otherpage/
                       


Title: Re: Reload whole page while loading data into TAB(smth happened, we have to do this)
Post by: mzeddd on August 17, 2012, 12:42:49 AM
Thanks Anton,

This is what I've been looking for.

//Valery