Updated ajax and logout function