Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting AJAX to work

    I have been trying to get this AJAX tutorial to work and it just doesnt seem to work. I can tell i am missing something super small but if someone could please help me. there are three different files that i am using and here they are. when i load the html in my firefox or ie. When i load it this is what i get when i load it. let me know if anyone has any help for me. thanks so much

    <% response.expires=-1dima(30)'Fill up array with names a(1)="Anna" a(2)="Brittany" a(3)="Cinderella" a(4)="Diana" a(5)="Eva" a(6)="Fiona" a(7)="Gunda" a(8)="Hege" a(9)="Inga" a(10)="Johanna" a(11)="Kitty" a(12)="Linda" a(13)="Nina" a(14)="Ophelia" a(15)="Petunia" a(16)="Amanda" a(17)="Raquel" a(18)="Cindy" a(19)="Doris" a(20)="Eve" a(21)="Evita" a(22)="Sunniva" a(23)="Tove" a(24)="Unni" a(25)="Violet" a(26)="Liza" a(27)="Elizabeth" a(28)="Ellen" a(29)="Wenche" a(30)="Vicky" 'gettheqparameterfromURLq=ucase(request.querystring("q"))'lookup all hints from array if length of q>0 if len(q)>0 then hint="" for i=1 to 30 if q=ucase(mid(a(i),1,len(q))) then if hint="" then hint=a(i) else hint=hint & " , " & a(i) end if end if next end if 'Output"no suggestion"ifnohintwerefound'or output the correct values if hint="" then response.write("no suggestion") else response.write(hint) end if %>
    Index.html
    Code:
    <html>
    	<head>
    		<script src="clienthint.js"></script>
    	</head>
    	<body>
    
    		<form>
    			First Name:
    			<input type="text" id="txt1"
    			onkeyup="showHint(this.value)">
    			</form>
    
    		<p>
    			Suggestions: <span id="txtHint"></span>
    		</p>
    
    	</body>
    </html>
    clienthint.js
    Code:
    var xmlHttp
    
    function showHint(str)
    {
    if (str.length==0)
    {
    document.getElementById("txtHint").innerHTML="";
    return;
    }
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
    alert ("Your browser does not support AJAX!");
    return;
    }
    var url="gethint.asp";
    url=url+"?q="+str;
    url=url+"&sid="+Math.random();
    xmlHttp.onreadystatechange=stateChanged;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    }
    
    function stateChanged()
    {
    if (xmlHttp.readyState==4)
    {
    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
    }
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
    // Internet Explorer
    try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    return xmlHttp;
    }
    gethint.asp
    Code:
    <%
    response.expires=-1dima(30)'Fill up array with names
    a(1)="Anna"
    a(2)="Brittany"
    a(3)="Cinderella"
    a(4)="Diana"
    a(5)="Eva"
    a(6)="Fiona"
    a(7)="Gunda"
    a(8)="Hege"
    a(9)="Inga"
    a(10)="Johanna"
    a(11)="Kitty"
    a(12)="Linda"
    a(13)="Nina"
    a(14)="Ophelia"
    a(15)="Petunia"
    a(16)="Amanda"
    a(17)="Raquel"
    a(18)="Cindy"
    a(19)="Doris"
    a(20)="Eve"
    a(21)="Evita"
    a(22)="Sunniva"
    a(23)="Tove"
    a(24)="Unni"
    a(25)="Violet"
    a(26)="Liza"
    a(27)="Elizabeth"
    a(28)="Ellen"
    a(29)="Wenche"
    a(30)="Vicky"
    
    'gettheqparameterfromURLq=ucase(request.querystring("q"))'lookup all hints from array if length of q>0
    if len(q)>0 then
      hint=""
      for i=1 to 30
        if q=ucase(mid(a(i),1,len(q))) then
          if hint="" then
            hint=a(i)
          else
            hint=hint & " , " & a(i)
          end if
        end if
      next
    end if
    
    'Output"no suggestion"ifnohintwerefound'or output the correct values
    if hint="" then 
      response.write("no suggestion")
    else
      response.write(hint)
    end if
    %>

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Does your server support asp? Are you running this on a server or your localhost?

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am running this on my localhost, is there any way to emulate a server enviroment on my machine?

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    yes download XAMPP google it
    ahh with asp you may need IIS? :S

  • #5
    New Coder
    Join Date
    Jul 2007
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can you give me a link to a quick tutorial on how to use this program? thanks

    I have installed the program and installed the perl addon and i tried to put my website into the asp folder, and ran localhost/asp/index.htm, and the wepage came up and i clicked and added some text and it broke saying object not found. anyways if someone could help me out please let me know. thanks
    Last edited by kansurr; 07-30-2007 at 05:16 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •