protected void Page_Load(object sender, EventArgs e)
{ if (Request.QueryString["UpLoad"] != null)
{
this.RegisterStartupScript("提示", "<script>alert('test')</script>");
}
}
<script type="text/javascript">var xmlhttp;
function Validation(){
xmlhttp =new ActiveXObject ("Microsoft.XMLHTTP");xmlhttp .open("Post","AddGameInf.aspx?UpLoad=true");
xmlhttp .onreadystatechange=OnMessageBack;
xmlhttp .send(null);
}function OnMessageBack()
{
if (xmlhttp .readystate==4&&xmlhttp .status==200)
{
alert("成功!");
}
}
</script><form id="form1" runat="server">
<input id="Button1" onclick="Validation();" type="button" value="上 传" />
</form>当我点击按钮时,为什么没反应? Ajax 不是异步发送请求吗?哪里出问题了。
{ if (Request.QueryString["UpLoad"] != null)
{
this.RegisterStartupScript("提示", "<script>alert('test')</script>");
}
}
<script type="text/javascript">var xmlhttp;
function Validation(){
xmlhttp =new ActiveXObject ("Microsoft.XMLHTTP");xmlhttp .open("Post","AddGameInf.aspx?UpLoad=true");
xmlhttp .onreadystatechange=OnMessageBack;
xmlhttp .send(null);
}function OnMessageBack()
{
if (xmlhttp .readystate==4&&xmlhttp .status==200)
{
alert("成功!");
}
}
</script><form id="form1" runat="server">
<input id="Button1" onclick="Validation();" type="button" value="上 传" />
</form>当我点击按钮时,为什么没反应? Ajax 不是异步发送请求吗?哪里出问题了。
try
{
if(window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}}catche(e){}
try
{
if(window.ActiveXObject)
xmlhttp =new ActiveXObject ("Microsoft.XMLHTTP");
else
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}xmlhttp .open("Post","AddGameInf.aspx?UpLoad=true",true);//加上true
var xmlHttp = false;
try {
xmlHttp = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
xmlHttp = false;
}
}
}
var url = "";
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = ShowResult;
xmlHttp.send(null);
}
function ShowResult() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {}
}
}
应该不是浏览器问题这句我不加参数回调函数里的对话框就弹出了。
xmlhttp .open("Post","AddGameInf.aspx");
这个应该对你有点帮助
http://download.csdn.net/source/1680276