|
Help needed -- DeepakSinha --
Hi all, I am new to ajax. I was trying to run an example but i am not able to get the values to the calling page. I am attaching the snippet of code I have written: <html xmlns=" http://www.w3.org/1999/xhtml " ><head runat="server"> <title>Untitled Page</title> <script language="javascript" type="text/javascript"> function showHint(str) { if (str.length == 0) { documeny.getElementById("txtHint").innerHTML = "" return } xmlHttp = GetXmlHttpObject() if (xmlHttp == null) { alert("Browser doesn't support HTTP Request"); return } var url = "GetHint.aspx" url = url + "?q=" + str url = url + "&sid=" + Math.random() alert(url) xmlHttp.onreadystatechange =stateChanged xmlHttp.open("GET",url,true) xmlHttp.send(null) } function stateChanged() { if ((xmlHttp.readyState == 4) || (xmlHttp.readyState == "completed")) { document.getElementById("txtHint").innerHTML = xmlHttp.resposeText } } function GetXmlHttpObject() { var objXMLHttp = null if (window.XMLHttpRequest) { objXMLHttp = new XMLHttpRequest() } else if(window.ActiveXObject) { objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP") } return objXMLHttp; } </script> </head> <body> <form id="form1" runat="server"> <div> First Name: <input type="text" id="txt1" onkeyup="showHint(this.value)" /> </div> </form> <p>Suggestions: <span id="txtHint"></span></p> </body> </html> In the called page I am writing the code like this protected void Page_Load(object sender, EventArgs e) { string arr; arr = new string ; // Fill up the array arr = "Anna"; arr = "Brittany"; arr = "Cinderella"; arr = "Diana"; arr = "Eva"; arr = "Fiona"; arr = "Gunda"; arr = "Hege"; arr = "Inga"; arr = "Johanna"; arr = "Kitty"; arr = "Linda"; arr = "Nina"; arr = "Ophelia"; arr = "Petunia"; arr = "Amanda"; arr = "Raquel"; arr = "Cindy"; arr = "Doris"; arr = "Eve"; arr = "Evita"; arr = "Sunniva"; arr = "Tove"; arr = "Unni"; arr = "Violet"; arr = "Liza"; arr = "Elizabeth"; arr = "Ellen"; arr = "Wenche"; arr = "Vicky"; // Get the q parameter from URL string q = Request.QueryString .ToUpper(); string hint = string.Empty; // Look up all hints from array if length of q > 0 if (q.Length > 0) { for (int i = 1; i <= 30; i++) { if (q == (arr .Substring(1, q.Length)).ToUpper()) { if (hint == "") { hint = arr ; } else { hint = hint + " , " + arr ; } } } } // Output "no suggestion" if no hint where found // or output the correct values if (hint == "") { Response.Write("no suggestion"); } else { Response.Write(hint); } } It may sound foolish for asking such simple question but I am really astounded by capabilities of AJAX. Please let me know what is the mistake that I am making. Regards Deepak Sinha |
|
-- JosephGuadagno --
I'm sorry but this group is meant for the support of using Ajax Professional for .NET not Ajax in general. Try posting this question in http://groups.google.com/group/ajax-world?lnk=li .Joseph Guadagno http://josephguadagno.net |