Your SlideShare is downloading. ×
Ajax
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Ajax

698

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
698
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
17
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • AJAX – has taken IT industry by storm. It might turn out to be one of the most demanded thing/in thing and hence, a brief presentation to understand AJAX. Be it anything that we are learning, asking 6 key questions is very important to get an overall idea of the same. The questions being – What, Why, Who, How, When and Where. So let’s being with what is AJAX? – not a technology, not a product … but an approach taken to develop Web Applications.
  • Inorder to understand what is this approach all about … let us first seek to know what the current approach is … At present, for every user interaction, the entire web page is rebuild. Even if a part of the entire page needs to be changed … we land up reloading the entire page. Which leads to … network traffic … slow speed … and most importantly … user experience goes down … user has to wait for loading of images … controls … which had already been loaded once!!! This is what AJAX asks us not to do.
  • Transcript

    • 1. AJAX – Asynchronous JavaScript and XML
    • 2. What is AJAX ? Ajax is a set of client side technologies that provides asynchronous communication between user interfaces and web server. So the advantages of using Ajax are asynchronous communication, minimal data transfer and server is not overloaded with unnecessary load.
    • 3. What problem does Ajax solve?
      • Unnecessary data transfers
      • Synchronous processing
      • Unnecessary processing by server
    • 4. Unnecessary data is transferred between client and server. For instance, the whole page is posted and refreshed even when we want small data of the page to be refreshed.
      • Unnecessary data transfers
    • 5. When a user requests for a page he has to wait until the complete round trip happens. In short, the request / response work on a synchronous model rather than asynchronous which makes user experience very difficult. How many times it has happened that you are requesting a page and you see the below screen…frustrating right.
      • Synchronous processing
    • 6. Because we are posting unnecessary information to the server, the server is overloaded with unnecessary processing.
      • Unnecessary processing by server
    • 7. Ajax Lifecycle
    • 8. XmlHttpRequest ?
      • Client Side Component.
      • Must be instantiated before use.
      • Use open() method to connect and retrieve response from the specified URL.
      • Handle onreadystatechange Event.
    • 9. XmlHttpRequest Component
      • Internet Explorer 5
      • Mozilla 1.0 – Netscape 7
      • Safari 1.2
      • Opera 7.6
      • Firefox
    • 10. Let’s see some coding : <html> <head> <script language = &quot;javascript&quot;> function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject (&quot;Microsoft.XMLHTTP&quot;); } return null; }
    • 11. Let’s see some coding : var xmlhttp; function showUser(str) { xmlhttp= GetXmlHttpObject(); if (xmlhttp==null) { alert (&quot;Browser does not support HTTP Request&quot;); return; } var url=&quot;getselected.php&quot;; url= url+&quot;?id=&quot;+str; xmlhttp.onreadystatechange= stateChanged; xmlhttp.open (&quot;GET“ ,url,true); xmlhttp.send(null); } 
    • 12. Coding : PHP [getselected.php]
      • <?php
      • //Display Message
        • echo “This is Ajax with PHP “;
      • ?>
    • 13. Coding: Javascript
      • function stateChanged()
      • {
      • if (xmlhttp.readyState==4)
      • {
      • document.getElementById(&quot;txtHint&quot;).innerHTML= xmlhttp.responseText;
      • }
      • }
      • - Continued
    • 14. Coding: Javascript
      • </script>
      • </head>
      • <body>
      • <form>
      • Select a User:
      • <select name=&quot;users&quot; onChange=&quot;showUser(this.value)&quot;>
      • <option value=&quot;1&quot;>Peter Griffin</option>
      • <option value=&quot;2&quot;>Lois Griffin</option>
      • <option value=&quot;3&quot;>Glenn Quagmire</option>
      • </select>
      • </form>
      • <br />
      • <div id=&quot;txtHint&quot;><b>Person information will be listed here.</b></div>
      • </body>
      • </html>
    • 15. Limitations of AJAX
      • JavaScript Implementations.
      • Debugging.
      • Security.
    • 16. One of the well known tools in building an efficient Ajax based application is jQuery. This programming language is often used in developing plug-ins for JavaScript and Ajax based applications.
      • JQuery
    • 17. <html> <head> <script src=&quot;jquery.js&quot; type=&quot;text/javascript&quot;></script> <script type=&quot;text/javascript&quot;> $(function() { $('#container-1').tabs(); }); </script> </head> <body> <h2>Simple Tabs</h2> <div id=&quot;container-1&quot;> <ul> <li><a href=&quot;#fragment-1&quot;><span>Tab1</span></a></li> <li><a href=&quot;#fragment-2&quot;><span>Tab2</span></a></li> <li><a href=&quot;#fragment-3&quot;><span>Tab3</span></a></li> </ul> -continued
      • Let’s see some coding using jquery
    • 18. <ul> <li><a href=&quot;#fragment-1&quot;><span>Tab1</span></a></li> <li><a href=&quot;#fragment-2&quot;><span>Tab2</span></a></li> <li><a href=&quot;#fragment-3&quot;><span>Tab3</span></a></li> </ul> <div id=&quot;fragment-1&quot;> <p>First tab is active by default:</p> <pre><code>$(&#039;#container&#039;).tabs();</code></pre> </div> <div id=&quot;fragment-2&quot;> Some text goes here for tab2 </div> <div id=&quot;fragment-3&quot;> some more text for tab3</div> </div> </body> </html>
      • Let’s see some coding using jquery
    • 19. Thank You

    ×