Data from API Flashcards
Distributed Computing
It allows 2 diff apps running on 2 diff machines to share info. it also allows 2 diff objects running in 2 diff process on same machine to share info.
Distributed technologies
- CORBA - Common Request Broker Architecture (14 languages)
- DCOM - Distributed Component Object Model - VB
- RMI - Remote Method Invocation - J2EE
- EJB - Enterprise Java Beans - Java
- Web Service - All technologies
- Remoting - .Net
Computing Architecture
Web Service Specification
- SOAP
- REST
- JSON
SOAP
Service Oriented Architecture Protocol
- Consumer sends XML request
- Provicer sends XML response
REST
Representational State Transfer
- Consumer sends a query request
- Provider sends XML response, optionally JSON
-?category=electronics
JSON
JavaScript Object Notation
Consumer and provider use JSON
API
JavaScript API
XMLHttpRequest
JS object used to communicate with an end point. it provides props and methods to handle communication.
var http = new XMLHttpRequest(); (BOM object)
XMLHttpRequest - open()
XMLHttpRequest - send()
XMLHttpRequest - Life Cycle Methods
onreadystatechange - f()
It executes the AJAX function and identifies the result. It defines actions to perform when response is ready.
It depends on “readystate” status, which includes
0: Initial
1:Pending
2:Processing
3:Completed
4:Ready [Response Ready]
responseText : returns string response
responseXML : returns XML response
responseHTML : returns HTML response
XMLHttpRequest - Drawbacks
XMLHttpRequest object doesn’t offer native support for synchronous requests, leading to potential blocking of the UI while waiting for a synchronous response.
No Built-in Support for Promises: XMLHttpRequest doesn’t natively support modern features like Promises, which can make code harder to read and maintain, especially when dealing with multiple asynchronous operations.
Explicit async config is required
the response is not directly in JSON format
It requires explicit parsing methods [JSON.parse()]
It is poor in error handling (cant track client and server side errors implicitly)
JavaScript Fetch Promise
Fetch is JS window object method
It is a promise.
It is implicitly Async
It provides implicit catch method, but cant catch the issues
It requires an explicit “throw”
It returns daat in binary format
Explit data parsing is required
fetch(“url”).then().catch().finally()
JQuery Ajax
Syntax:
$.ajax({
method:””,
url:””,
data:{},
success: (),
error: ()
})