Difference Between AJAX and RestAPI's. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 17

Difference Between AJAX and RestAPI's.

Any difference you know... 2) in case of ajax the returned data is in the form of JSON, can it be called as RestAPI ?

20th Apr 2019, 7:09 PM
Aaditya Deshpande
Aaditya Deshpande - avatar
7 Answers
+ 9
So my understanding based on that is that AJAX refers to client side technologies whereas REST refers to server side protocols. Both are related to increasing the efficiency of web data flow.
21st Apr 2019, 12:05 AM
Sonic
Sonic - avatar
+ 8
Sonic,Daniel Adam Aaron Stone so if my ajax is returning a data in JSON format can it be treated as a REST api ? Thank you for your answers.
21st Apr 2019, 1:47 PM
Aaditya Deshpande
Aaditya Deshpande - avatar
+ 5
AJAX is an method to asynchronously load content, whilest REST is an architecture priciple for scaleable distributed API's.
21st Apr 2019, 12:09 PM
Daniel Adam
Daniel Adam - avatar
+ 5
In lay terms, You use rest API in your back-end, process data and output it to a webpage in JSON format. In your front-end, you use AJAX to access the data from the API and do anything you like with this data on your front end. Also note that AJAX can be also used in back-end as in the case of PHP AJAX. Real life example: A currency converter website provides *DATA* containing current currency rate and symbols through rest API. You access these DATA from you application through AJAX and make necessary conversions based on your user inputs and the conversion rates based on your question 2: The answer is no! REST API is the technique used in presenting this DATA
22nd Apr 2019, 1:30 PM
Victor Mbamara
Victor Mbamara - avatar
+ 3
Ajax is asynchronous JavaScript and XML, it basically allows the web app to make asynchronous http requests back to the server to fetch some data. Rest API is a backend server architecture that makes it easier to build APIs. It's just a set of convention or practices you follow when building APIs
21st Apr 2019, 5:34 PM
jay
+ 3
No. JSON has nothing to do with REST. An API is an application interface. An Application is an stateful system. A distributed system (like an orchastration of webservices) makes it difficult to represent a state (as services are independent). So REST propagates to use HATEOAS (hypermedia as the engine of application state). Together with resources (as states) you'll have a statemachine, that is: a distributed application. (REST has nothing to do with frameworks or technology, it's a principle, but implementation with http and json works very well on internet environments for a bunch of reasons).
22nd Apr 2019, 8:50 AM
Daniel Adam
Daniel Adam - avatar