In my Django application I would like to know if the browser the client is using has AJAX or not. This is because I have, for example, profile editing. I have a version that edits the user’s profile in-place and another one that redirects you to an edit page.
I know that most browsers have AJAX nowadays, but just to make sure, how can I check that in a Django application?
I believe that the correct thing would be to use some sort of graceful degradation and check for ajax in the request using Django’s
request.is_ajax()methodhttps://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.is_ajax
In your view there would be something like