Hi,
I am using php connector for some server side data provision (into DataView). What is the accepted method to redirect user in the case of being logged out of the application ?
I understand a 401 code should be issued and tested for in the browser but how to do the issue and detect ? Have tried the whole XMLDoc,ResponseText etc but no joy as yet.
Any ideas on how to achieve ? Thanks in advance,
Steve
As this is an AJAX call, redirect code will not work.
Still you can return code 401 and use onAjaxError in the client side code that will redirect page to the login or trigger any other reaction.
You can return some plain-text, non-xml message from server side script and use
docs.dhtmlx.com/api__dhtmlxajax_ … event.html
Stanislav,
Yes, that’s what I was getting at. Thanks for the response.
What is the appropriate way to issue the 401 from the connector side ?
Thanks in advance, 
Steve
There is no API for header modification, so in case of PHP code the best attempt will be
http_response_code(401);
echo "Session expired";
die();
It is not very elegant, but effective
Stanislav,
Thanks. Had already tried this but was hoping for something that would trigger onAjaxError so I could handle better than on every callback. Using this code does not trigger the error event.
Any ideas ?
Steve
Ok so an update. My error:
http_response_code(401);
Does trigger the onAjaxError event when used with window.dhx4.ajax. My issue is that I was using grid.load() and dataview.load() methods and although they are ajax under the hood, the ajax error event is not called when a 401 is set via this method.
And of course, the methods load the respective elements with data. So if I want to trigger this behaviour, I expect I would need to use an ajax call and then load the data into the elements (grid and dataview) manually if that makes sense ?
What is the most appropriate way of doing thjis ? Have had a go with
xmlDoc.responseText.toString
From this thread: viewtopic.php?f=14&t=11047
But no joy. Am I correct in saying for my need, I will need to do ajax call with using the above type of loading code ? If so, what is wrong with the code I have to perform this ?:
[code] window.dhx4.ajax.get(“php/sp_comments_data.php?id=”+id+"&projid="+data_view_1.getSelected(),function®{
//grid_1.load("php/sp_comments_data.php?id="+id+"&projid="+data_view_1.getSelected(),doOnCommentGridLoaded);
var xml = r.xmlDoc.responseText.toString();
xml = xml.replace(/\r/g, "");
xml = xml.replace(/\n/g, "");
xml = xml.replace(/\t/g, "");
alert (xml);
grid1.loadXMLString(xml);
d.progressOff();
});[/code]
Thanks in advance,
Steve
To load component from AJAX response you can use code like next
dhx4.ajax.get("php/get.php", function(response){
myGrid.parse(response.xmlDoc.responseText,"xml")
});