How to make a AJAX call?

In the following code I want to fetch data from my doctype of Item and make a new entry in the Cart doctype using AJAX:

Doctype details:

  1. Item(child doctype) → (item_name, price, quantity)
  2. Cart(parent doctype) → (user, Item Table, total_price)

@Hamza3351 check this Frappe Ajax Call

So according to documentation, I have made a function but it is giving an error:

Following is the code of function:

b1

Sending some hardcoded values into the function:

b2

I am confused in using frappe.call here…

In the following discussion I have solved this issue by using another approach called async/await, here is the link: