It doesn't matter if you use the RPC or RESTful APIs from an ajax perspective, but overall you might think of the RESTful API as a well-organized, well-named collection of remote procedural calls.
Is this common practice for a web application and why?
This is useful because you do not need to duplicate code in order to have regular CRUD operations for multiple data objects.
Another thing to keep in mind is that if you have a consistent convention of API call names with which you can write AJAX functions to interact with, you will write and maintain much less code over time on the JavaScript application side. assuming you donβt do anything strange in your code.
An example of when / as it would be good practice would be if you wrote a basic method designed to automatically determine your AJAX URL depending on what you are doing and where you are, and it automatically determines that POST method to use depending on the type of operation ... then you literally write one ajax function and apply it to things, rather than writing completely separate ajax methods for each action element.
source share