Added functionality to responde to XMLHttpRequests