var xmlHttp;
function Validation()
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
var name = document.getElementById("Text1");
xmlHttp.open("post","run.aspx?name="+name.value);
xmlHttp.onreadystatechange = onMessage();
xmlHttp.Send(null);
}
function onMessage(){
if(xmlHttp.readystate == 4 && xmlHttp.status == 200)
{
document.getElementById("now").innerHTML = "查询完成";
}
else if(xmlHttp.readystate == 1)
{
document.getElementById("now").innerHTML = "正在发送请求";
}
else if(xmlHttp.readystate == 2)
{
document.getElementById("now").innerHTML = "响应内容";
}
else if(xmlHttp.readystate == 3)
{
document.getElementById("now").innerHTML = "正在解析内容";
}
}大家看下上面写的有错误吗???
function Validation()
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
var name = document.getElementById("Text1");
xmlHttp.open("post","run.aspx?name="+name.value);
xmlHttp.onreadystatechange = onMessage();
xmlHttp.Send(null);
}
function onMessage(){
if(xmlHttp.readystate == 4 && xmlHttp.status == 200)
{
document.getElementById("now").innerHTML = "查询完成";
}
else if(xmlHttp.readystate == 1)
{
document.getElementById("now").innerHTML = "正在发送请求";
}
else if(xmlHttp.readystate == 2)
{
document.getElementById("now").innerHTML = "响应内容";
}
else if(xmlHttp.readystate == 3)
{
document.getElementById("now").innerHTML = "正在解析内容";
}
}大家看下上面写的有错误吗???
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
的时候一般还会对别的浏览器做判断,
基本上用的时候只用写
if(xmlHttp.readystate == 4 && xmlHttp.status == 200) 就可以了。
{
string name = Request.QueryString["name"];
if (name != null)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["test"].ConnectionString);
SqlCommand cmd = new SqlCommand("selectTest", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@name", SqlDbType.VarChar, 40).Value = name;
conn.Open();
int count = (int)cmd.ExecuteScalar();
conn.Close();
if (count == 0)
{
Response.Write("<script>alert('该用户可以用!');</script>");
}
else
{
Response.Write("<script>alert('已被注册!');</script>");
}
}
else
{
Response.Write("<script>alert('error!');</script>");
}
}
var DStatus="";
var type="";
var pid="";
var did="";
function DBalternating(type,pid,did)
{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.onreadystatechange=statechange; xmlhttp.Open("POST","DBalternating .aspx?type="+type+"&pid="+pid+"&did="+did+"",true); xmlhttp.Send(); }
function statechange()
{
if(xmlhttp.readystate==4)
{
if(xmlhttp.status==200)
{
// DStatus=xmlhttp.responseText;
Message=xmlhttp.responseXML.getElementsByTagName("list");
type=Message[0].getElementsByTagName("type")[0].text;
pid=Message[0].getElementsByTagName("pid")[0].text;
did=Message[0].getElementsByTagName("did")[0].text;
window.open('showvideo.aspx?type='+type+'&patientid='+pid+'&doctorid='+did+'');
}
}
}
JS中 xmlHttp.onreadystatechange = onMessage();这句不能带括号~!!!写成这样就OK啦~~~~
xmlHttp.onreadystatechange = onMessage;