JS: var XMLHttp = false;
try
{
XMLHttp = new ActiveXObject("Msxml2.xmlHTTP");
}
catch(e)
{
try
{
XMLHttp = new ActiveXObject("Microsoft.xmlHTTP");
}
catch(e2)
{
XMLHttp = false;
}
}
if(!XMLHttp && typeof XMLHttpRequest!= null)
{
XMLHttp = new XMLHttpRequest();
}
if(!XMLHttp)
{
alert("失败");
}
function Verify()
{
debugger;
var name = document.getElementById("txtbAccount").value;
if(name.length==0){
alert('对不起,用户名不能为空!');
}
else{
var url = "AppendUserRole.aspx?account="+name+"&rnd="+Math.random();
XMLHttp.open("GET",url,true);
XMLHttp.send(null);
XMLHttp.onreadystatechange =check_Name;
}
}
function check_Name()
{
if(XMLHttp.readystate == 4)
{
if(XMLHttp.responseText == "true")
{
alert("用户名存在..");
}
}
}
Page_Load():
if (Request.QueryString.Count > 0)//判断用户是否存在
{
if (Request.QueryString["account"] != null)
{
string name = Request.QueryString["account"].ToString();
if (GovernUserRolesHelper.IsUserExist(name))
{
Response.Write("true");
}
else
{
Response.Write("false");
}
Response.Flush();
Response.End();
}
}
分析:其实不是IE问题,问题来自于由于每次生成的URL都是一样,因为Get请求很特殊,没有返回内容(其实就是为了触发一下某个事件,在回调函数中调用另一个请求来刷新页面),所以IE自作主张的把这个请求返回的空页面给cache掉了。
解决办法:在生成URL的时候在后面跟加了一个随机数"这样IE这个SB不会在cache掉页面了吧""""
var url = "AppendUserRole.aspx?account="+name+"&rnd="+Math.random();
浙公网安备 33010602011771号