var xmlHttp;
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
} catch (e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}return xmlHttp;
}
试试这个,因为你只考虑了IE浏览器,没有考虑其他浏览器兼容
还有,JS可以操作cookie的,没必要到php文件里去做,这样浪费效率。
试试这三个函数
function setCookie()
{
if(arguments.length==2)
{
var name=arguments[0];
var value=arguments[1];
var Days = 1;
var exp = new Date();
exp.setTime(exp.getTime() + Days*24*60*60*1000/2);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";
}
else if(arguments.length==3)
{
var name=arguments[0];
var value=arguments[1];
var Seconds = arguments[2];
var exp = new Date();
exp.setTime(exp.getTime() + Seconds*24*60*60*1000/2);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/";
}
else
{
alert("操作错误!");
}
}
function getCookie(name)
{
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString()+";path=/";
}