40 likes | 143 Views
AJAX A synchronous J avaScript A nd X ML. 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
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