i have a problem while making an ajax request using xajax. The issue is that i dont want to start the session on the server unless it is completely necessary. For an xajax call, the response can not be send without the existance of the session, so i am forced to start it.
So, assuming that session is not started in the moment where the user makes the call from the client side, if i have this function on the server side:
function example() {
$response = new XajaxResponse();
$response->script("alert('hello')");
return $response;
}
I get an error. I can not trace the error in chrome or explorer, but in firefox i get an uncaught object exception in the core of the library. If i start the session before making the return, it "works":
function example() {
session_start();
$response = new XajaxResponse();
$response->script("alert('hello')");
return $response;
}
I say "works" because it works in a partial way. In firefox the ajax call goes through perfectly, however in chrome/ie i need to make 2 calls: the first time nothing happens, while the second is ok.
The only solution i can think now is a very dirty one. It should be to create an xajax function to start the session:
function startSession () {
session_start();
}
And then, from the client side make two calls in this way:
xajax_startSession(); xajax_example();
With this approach i solve the problem of "first execution" in chrome/ie, but is a very bad idea to have to add an extra call to every single xajax call :(
Thanks a lot again for your help