eng.mohamed_elqpany Posted October 29, 2006 Share Posted October 29, 2006 i need your help in learning AJAX. i have a problem in my first example in AJAX. It's supposed to recieve a response from the server side but no response at all (null).this my codehtml file <html><head><script src="clienthint.js"></script> </head><body><% response.write("fadf") %><form> First Name:<input type="text" id="txt1" name="txt"><input type="button" name="btn1" value="Click" onclick="showHint(txt.value)"></form><p>Suggestions: <span id="txtHint"></span></p> </body></html> and this is the java script file var xmlHttpfunction showHint(str){if (str.length==0){ document.getElementById("txtHint").innerHTML=""return}xmlHttp=GetXmlHttpObject()if (xmlHttp==null){alert ("Browser does not support HTTP Request")return} alert(str)var url="gethint.asp"url=url+"?q="+strurl=url+"&sid="+Math.random()xmlHttp.onreadystatechange=stateChanged xmlHttp.open("POST",url,true)alert("Escap1")xmlHttp.send(null)} function stateChanged() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ document.getElementById("txtHint").innerHTML=xmlHttp.responseText alert(xmlHttp.responseText)} } function GetXmlHttpObject(){ var objXMLHttp=nullif (window.XMLHttpRequest){objXMLHttp=new XMLHttpRequest()}else if (window.ActiveXObject){objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")}return objXMLHttp} and this is the server side code <%dim a(30)'Fill up array with namesa(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"'get the q parameter from URLq=ucase(request.querystring("q"))'lookup all hints from array if length of q>0if 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 nextend if'Output "no suggestion" if no hint where found'or output the correct valuesif hint="" then response.write("no suggestion")else response.write(hint)end if%> i hope u help me. and i need to know the basics of that technology.and if you can provide an open source code example.thanx.. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 30, 2006 Share Posted October 30, 2006 Try changing this:xmlHttp.open("POST",url,true)to this:xmlHttp.open("GET",url,true)When requesting data, you should use GET instead of POST.Also, instead of sending the request as null, use the empty string:xmlHttp.send("")And try adding an alert to your callback function to make sure it's even getting executed: function stateChanged() { alert("stateChanged called: " + xmlHttp.readyState) if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { document.getElementById("txtHint").innerHTML=xmlHttp.responseText alert(xmlHttp.responseText) } } Link to comment Share on other sites More sharing options...
eng.mohamed_elqpany Posted October 31, 2006 Author Share Posted October 31, 2006 i tried that but no response. i want to ask a question. what the structure of the .asp page? does there must be some beginning and finishing?my page contain just the code above and this alert "alert(xmlHttp.responseText)" just returns the whole code written in the page.i just need i help i know that i'm so beginner.regards, Link to comment Share on other sites More sharing options...
jesh Posted October 31, 2006 Share Posted October 31, 2006 What happens if you just visit your ASP page (gethint.asp) in your browser by typing in the address in the address bar? Do you see "no suggestion"? What happens if you visit "gethint.asp?q=ci", do you see "Cinderella"? Or, when you do these tests, are you only seeing your ASP code? Link to comment Share on other sites More sharing options...
eng.mohamed_elqpany Posted November 1, 2006 Author Share Posted November 1, 2006 i only see my codei just need help please. Link to comment Share on other sites More sharing options...
aspnetguy Posted November 1, 2006 Share Posted November 1, 2006 IIS is not setup correctly then if you are seeing the code. Link to comment Share on other sites More sharing options...
eng.mohamed_elqpany Posted November 1, 2006 Author Share Posted November 1, 2006 what the exact problem and how to fix it please?thanx for ur answer Link to comment Share on other sites More sharing options...
justsomeguy Posted November 1, 2006 Share Posted November 1, 2006 The exact problem is that IIS is not set up to properly handle ASP pages.http://www.google.com/search?hs=jjd&hl...amp;btnG=Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now