concept AJAX in category ejb

appears as: AJAX
EJB 3 in Action, Second Edition

This is an excerpt from Manning's book EJB 3 in Action, Second Edition.

New to Java EE 7 is JSON support (JSR 353). JSON stands for JavaScript object notation and it’s a compact encoding of data. You’ll use JSON when we cover the RESTful web services. RESTful web services often use JSON as the response. This is useful if you’re building a website that’s heavily interactive with lots of JavaScript code. XML is very verbose, consumes bandwidth, and also consumes resources on both the client and server. When using an interactive web application that uses AJAX, JSON is definitely the approach to take.

Two other approaches taken to get around the limitations of the HTTP request–response model in the browser are AJAX and Comet. We’ll compare each in the following section to WebSockets, but they aren’t a complete solution. AJAX enables asynchronous calls from the web browser after the page has been loaded to retrieve either a partial page or data without a full page reload. Data is often returned in JSON (JavaScript Object Notation) format. AJAX is still a pull—the browser has to initiate the request. To create the impression of server push, many pre-HTML5 web applications coupled polling with AJAX, which is fine for email applications but not completely acceptable when near-real-time behavior is expected.

14.2.2. WebSockets versus AJAX

AJAX (Asynchronous JavaScript and XML) is an older technique for exchanging between the client and server. Like WebSockets, the client initiates AJAX invocations. But unlike WebSockets, the invocations are synchronous—the client sends a message to the server and the server responds. After the client receives the server’s message, the connection is closed. The communication is asynchronous from the perspective of the user because the AJAX call is performed on a separate thread so that the UI doesn’t freeze.