Asynchronous JavaScript XMLHttpRequest (XHR), commonly known as Ajax, has become an important part of web applications over the last few years. With the advent of single-page applications and JavaScript application frameworks such as Angular, Vue, and React, this technique of web development has risen exponentially. In this recipe, we will implement an Ajax request to facilitate asynchronous communication between the backend and frontend.
Dealing with XHR requests
Getting ready
Flask provides an easy way to handle the XHR requests in the view handlers. We can even have common methods for normal web requests and XHRs. We can just check for a flag on our request object to determine the type of call and act accordingly.
We will...