The best user experience would be to ask the user to login again, establish a new login session and resume back in the place that the user last was in the browser.
That requires doing login in a way that preserves where the user was in the browser like via a login overlay (on the current page) that can become visible, do it's thing via ajax and then go away when successful, leaving the user where they were (there are other ways to do that too).
But, all of this depends upon how much time you want to invest in the user experience for this particular case. If you think it is rare and the unsaved state the user might have is low, then you can just bump them to the login page and make them start their session over. If it's a regular occurrence or if the user has lots of unsaved state that they won't want to lose, then you will want to invest in a mechanism for them to login again without losing that state.
If what you're asking is how would you code in the client for the session going away, that will depend upon what your server returns to the ajax call when it receives a request with an invalid or expired session. Based on what behavior the server returns, you need to make sure you can handle that in your ajax handling. If it's an error, then you need to handle the error conditions. If it's a certain type of valid ajax response, you need to make sure you are handling that.
If you are already producing a known error return condition from the ajax call from the server when the session is invalid on an ajax call, then you just need to fix your client code to detect that condition. We'd have to see what the error condition is and see your client ajax code to know what specifically to advise.