IT2357 - Web Technology Lab - AJAX

8

description

IT2357 - Web Technology Lab - AJAX

Transcript of IT2357 - Web Technology Lab - AJAX

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 2

    Develop an application using Ajax program for displaying the message Hello Ajax World. Use button and enable click event to display the message and name the button as Get Message. PROGRAM: Hello.html Hello AJAX function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200)

    { document.getElementById("myDiv").innerHTML =

    xmlhttp.responseText; } } xmlhttp.open("GET","rec.txt",true); xmlhttp.send(); } Welcome

    Get Message

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 3

    rec.txt Hello Ajax World

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 4

    OUTPUT:

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 5

    Develop an Ajax application to display the text entered in the text field in a web page with a Welcome message. (eg: Welcome Anna University). Also display the current date and time of the server on the page. PROGRAM: Welcome.html Welcome AJAX function showName(str) {

    if (str.length == 0) { document.getElementById("txtHint").innerHTML = ""; return; } else { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

    document.getElementById("txtHint").innerHTML = xmlhttp.responseText;

    } }

    xmlhttp.open("GET", "getdatetime.jsp?q=" + str, true); xmlhttp.send(); } } Start typing a name in the input field below: Student Name :

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 6

    getdatetime.html Date and Time

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 7

    OUTPUT:

  • BHUVANESWARAN B / AP (SS) / CSE / REC - 8