in my code responseText is not working. It is supposed to display, text entered in the text box +" :Your request has been seen by syam"
<html>
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript">
var xmlHttpRequest;
function sSignature(str) {
xmlHttpRequest = new XMLHttpRequest();
xmlHttpRequest.onreadystatechange = function() {
if (xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200) {
document.getElementById("target").innerHTML = xmlHttpRequest.responseText;
}
}
xmlHttpRequest.open("GET", "AjaxResponse.aspx?q=" + str, true);
xmlHttpRequest.send();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
enter a string :<input type="text" id="textbox" onkeyup="sSignature(this.value)"/>
<span id="target">text should change here</span>
</div>
</form>
</body>
</html>
In the code-behind page, in page_load()
string sRequest = Request.QueryString["q"];
var sResponse = sRequest+ " :Your request has been seen by syam";
Response.Write(sResponse);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…