<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SubmissionThrottlingDemo2.aspx.cs" Inherits="AJAX.SubmissionThrottlingDemo2" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

    <title>AJAX Design Pattern: Submission Throttling - Web API</title>

    <style type="text/css">

        #Text1

        {

            z-index: 1;

            left: 92px;

            top: 169px;

            position: absolute;

            width: 240px;

        }

        #txtName

        {

            z-index: 1;

            left: 76px;

            top: 168px;

            position: absolute;

            width: 153px;

        }

    </style>

   

    <script type="text/javascript" >

        var timer;

        var count = 0;

        var xmlhttp;

 

        try {

            // Code for IE7+, Firefox, Chrome, Opera, Safari

            xmlhttp = new XMLHttpRequest();

         }

        catch (try_older_microsoft) {

            try {

                // Code for IE6, IE5

                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

            }

            catch (other) {

                xmlhttp = false;

                alert("Your browser doesn't support AJAX!");

            }

        }

 

        function init() {

            //set a timer to call the convertName function in 3 seconds

            timer = setInterval("convertName()", 3000);

        }

 

        function uninit() {

            //stop the timer

            clearInterval(timer);

            alert("Timer cleared");

        }

 

        function convertName() {

            var name = document.getElementById("txtName").value;

           

            // make an async request to convert the letters in the textbox

            xmlhttp.open("GET", "http://cis-iis2.temple.edu/users/pascucci/CIS3342/CoreWebAPI/api/AJAXWebService/ConvertName/" + name, true);

            //xmlhttp.setRequestHeader("Access-Control-Allow-Origin", "*");

            xmlhttp.onreadystatechange = onCompleteName;

            xmlhttp.send();

            count++;

        }

 

        function onCompleteName() {

            document.getElementById("display_area").innerHTML = xmlhttp.responseText + " [ " + count + "]";

        }

 

    </script>

   

</head>

<body bgcolor="#669999">

    <form id="form1" runat="server">

    <div>

   

        <asp:Label ID="Label1" runat="server" Font-Size="24pt"

                   Text="Design Pattern: Submission Throttling Demo"></asp:Label>

        <br />

        <br />

        <div id="display_area"></div>

        <br />

        <br />

        <asp:Label ID="Label2" runat="server"

            style="z-index: 1; left: 12px; top: 169px; position: absolute; bottom: 428px; width: 84px"

            Text="Name: " Font-Size="14pt"></asp:Label>

        <br />

        <br />

        <br />

        <br />

        <input id="txtName" type="text" onfocus="init();" onblur="uninit()" />

        <br />

        <br />

        <br />

   

    </div>

    </form>

 

</body>

</html>