1 (edited by WhiteEcho 2007-03-07 8:58:17 PM)

Topic: Default redirect or behavior when "No response processor is available"

When my session expires (I have my own session handler, it is SQL-based, uses a Cookie and allows arrays, as well as clustered servers, but it is not the source of the problem), then the debug window will return the header template (through Smarty) , followed by a "Error: No response processor is available to process the response from the server. Content-Type: text/html" message.

I wonder if it would be possible to set up a specific behavior in Xajax, in order to prevent this from happening. In my case a redirect to the login page, or even to the same exact page, to reset the primary status prior to AJAX, would be awesome. I guess it would have to be something in the Javascript code.

Thanks!

Re: Default redirect or behavior when "No response processor is available"

I wouldn't solve this problem on client-side - I guess it's possible to do it in that way, but in my opinion it doesn't makes sense to return a complete html page to an ajax request when the session expires and let JS solve that problem - too much overhead wink

I have a similar case (smarty based cms on a webcluster with 4servers, mysql sessions,..) and I override the xajax function call when the session expires


here's a sample

if (
        (
            ($_SESSION['CMS']['user_id'] == "")
            OR
            ($_SESSION['CMS']['user_id'] == 0)
        )
        AND
            ($_REQUEST['xajax'] != "openLogin")
        AND
            ($_REQUEST['xajax'] != "initApp")
        AND
            ($_REQUEST['xajax'] != "loginUser")
        ) {
            $_POST['xajax'] = "SessionExpired";
            }

function SessionExpired($aFormValues=false) {

    $objResponse = new xajaxResponse();
    $objResponse->script("clear_tiny_instances();");

    $objResponse->assign("CMS","innerHTML","");
    $objResponse->loadcommands(openLogin(array()));
    $objResponse->assign("DivLoginFormError","innerHTML","Your session expired");

    return $objResponse;
}

Re: Default redirect or behavior when "No response processor is available"

WhiteEcho,

If you wish, your php can return a redirect command to xajax and xajax will pass the redirect to the browser so that you can forward the user to a login page.  (at least as of xajax 0.5 beta 2)

q_no,

Nice solution.  I like how you redirect to a special function when the session has expired...  A further refinement might be to also clear the parameters (as the special function won't need them).  You should be able to clear them with something like:

$_POST['xajaxargs'] = '';

I'm not 100% sure on the syntax, might have to use $_POST['xajaxargs[]'] = '';  Still... interesting solution.

// Joe

xajax Developer
Connect to me on LinkedIn:
http://www.linkedin.com/in/calledtoconstruct

4 (edited by q_no 2007-03-07 11:06:59 PM)

Re: Default redirect or behavior when "No response processor is available"

CtC wrote:

q_no,

Nice solution.  I like how you redirect to a special function when the session has expired...  A further refinement might be to also clear the parameters (as the special function won't need them).  You should be able to clear them with something like:

$_POST['xajaxargs'] = '';

I'm not 100% sure on the syntax, might have to use $_POST['xajaxargs[]'] = '';  Still... interesting solution.

Your are right. I don't  really need the arguments anymore in this case - but if you think a little bit further - you can for example store the complete request somewhere (session,memcache, DB or textfile), open the login screen and afterwards you can continue with the last action.
That's really exiting in a CMS when the user needs too much time to type a text and the session expires on saving it... wink unfortunately I haven't had enough time to go that step... but that's a must-have in my opinion for a nice workflow wink