I’m making requests with AJAX only, most of my requests returns html which i load to div#content (not only, bu let say its the most common action). Problem occurs when I have to send something like error message, for example when user session expired – then i have to ‘clear user desktop’ (replace whole body, not only #content). Ajax loading func, don’t know what it will get, so server has to send some additional information, what to do with its response.
I thought about custom header, but wanted to know if there are some other possibilities or ‘best practices’ for this problem.
You could send back more than just a HTML fragment to put in
#content, but instead a fragment of JavaScript to be executed instead, or else a JSON document with a key to describe how to interpret it.