40 likes | 147 Vues
AJAX (Asynchronous JavaScript and XML) enhances web applications by allowing client-side scripts to interact with server-side resources without requiring a full page reload. It addresses the limitations of traditional client-side JavaScript, which is restricted from direct server access, and server-side languages that cannot update the client’s browser after page load. By using AJAX, developers can create dynamic and interactive user experiences, efficiently transferring data using the XMLHttpRequest object. While raw AJAX coding is possible, libraries like jQuery simplify the process, making web development more effective.
E N D
AJAXAsynchronous JavaScript And XML BTM 395: Internet Programming
Limitation of client-side programming • Client-side programming (i.e. JavaScript) cannot access the server directly • No access to databases • No reading or writing files on the server • Only exception is content available to HTML, like images and CSS • Advantages are for security • Protects web servers from malicious JavaScript code
Limitation of server-side programming • Server-side programming (e.g. PHP, ASP, JSP) cannot access the client’s browser directly • Once the web page is served, it cannot be changed further • No interactive responses to user actions • Any interaction requires reloading the page and responding to GET, POST, cookies or sessions • HTTP is a stateless protocol • Once the server sends a page to the client, there is no active connection maintained • Thus the server cannot know what the client does until a new page request is made
Ajax: marrying client- and server-side web programming • Ajax permits web clients to interact with the web server without having to reload the entire page • Basic procedure • JavaScript creates an XMLHttpRequest (Ajax) object • This Ajax object makes a call to a server-side script • Normally, must be the same server that provided the HTML page, but there are secure ways to get around this • The Ajax object receives data in response • The received data can be manipulated through JavaScript • Raw Ajax coding is possible, but programmers normally use frameworks like jQuery to make it simpler