Click here to Skip to main content
13,193,468 members (54,229 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I have written the following AJAX code for getting response from .aspx page. But getting an error htmlfile: Unknown Runtime Error for the below line in bold:
function CheckCode() {
var sname = document.getElementById('<%=txtName.ClientID %>').value;
if (sname != "" || sname != null) {
request = new XMLHttpRequest();
request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) {
document.getElementById('<%=lblNameError.ClientID %>').innerHTML = request.responseText;
}
}
var loc = "CheckCode.aspx?name=" + sname;
request.open("GET", loc, true);
request.send();
}
in Checkcode.aspx
 
//..some code
if (dr.Read())
{
checkno = 0;
Response.Write("already exists");
}
else
{
checkno = 1;
Response.Write("continue");
}
Posted 16-May-11 22:10pm
Updated 16-May-11 22:41pm
v2
Comments
SAKryukov 17-May-11 15:53pm
   
Not clear, because you need to show in which line of code it happens. You need to catch all exception and provide exception dump with stack and all inner exceptions, recursively.
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

When you are sendind any response using "Response.Write(........)", then it may have some previous value.
try to clear it first and then ending it.

try this
=======================================================
Response.Clear();   //Add this line
if (dr.Read())
{
checkno = 0;
Response.Write("already exists");
}
else
{
checkno = 1;
Response.Write("continue");
}
Response.End();    //And add this

=======================================================
And you are good to go. :)
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
ankitmahesh91186 14-Nov-11 6:37am
   
I also having the same issue.. plz help
thatraja 14-Nov-11 6:48am
   
Don't you check the link in my answer? See that for solution(s)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171018.2 | Last Updated 21 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100