We will be covering two components that are necessary to perform this operation.
- XMLHttpResponse(method/URL) is an AJAX object. It is used in sending data to the webserver. Create an XMLHttpResponse object and pass your value through it.
- JSON.stringfy is a common JSON method. When passing data to a web server data has to string, and the .stringfy method helps us do that.
2. Now, we come to the flask code. The data has been passed to the python function and now we have to receive it. Remember, we have sent the data in JSON string format and now we have to open it. json.loads, it receives the JSON string and converts it to a Python dictionary.
You can also refer to my other tutorials –