Calling Ajax in Odoo 14

AJAX can be used to generate dynamic, interactive web pages (Asynchronous JavaScript and XML). The browser makes an HTTP request to the server in order for AJAX to function. The server then processes the browser’s request, generates the response, and sends it back. AJAX updates the website page rather than reloading it entirely. We don’t have to reload the full page while utilizing AJAX.

We can check how to call ajax in Odoo in this article. Here is a condensed illustration of how the ajax service is used in Odoo 14.

JavaScript Code Block

It could do an RPC to load some data based on the example. The module may then return a promise in such a scenario. The module system will then hold off on registering the module until the promise has been fulfilled.

There is an ajax call made in the website event module to register the event tickets.

An ajax form is called when the register button is clicked. Ie,

Register

Here, the form is displayed without completely reloading the website.

We must first define the form and button templates for this ajax call. The button can be tailored to our needs.

Template for attendees’ information:



Register

Next, we can use the button’s click function to make an ajax call. Include the web.ajax first.

Specifically,var ajax = require("web.ajax");

Then, we can use ajax to call the button’s onclick method.


When the button is clicked, the data is loaded using jsonRpc, and the post method is utilized as the HTTP request method. In this manner, we may use ajax in Odoo to develop interactive web pages

Hire Dedicated Developers

Reach new heights with WanBuffer’s offshore engineering team. Our team of over 50 highly skilled and dedicated full-stack software engineers have the expertise and experience to tackle your key technology challenges, improve efficiency and reduce expenses. Let us help you drive your business forward today.

Schedule Meeting