﻿
var xmlobj; //定义XMLHttpRequest对象 

function CreateXMLHttpRequest2() 
{ 
if(window.ActiveXObject) //如果当前浏览器支持ActiveXObject则创建ActiveXObject对象 
{ 
xmlobj = new ActiveXObject("Microsoft.XMLHTTP"); 
} 
else if(window.XMLHttpRequest) //如果当前浏览器支持XMLHttpRequest则创建XMLHttpRequest对象 
{ 
xmlobj = new XMLHttpRequest(); 
} 
} 

function Validate2(id) //主程序函数 
{ 


CreateXMLHttpRequest2(); //创建对象 

var showurl = "add_cart2.php"; //构造URL 

xmlobj.open("GET", showurl, true); //调用validate.php 
xmlobj.onreadystatechange = StatHandler; //判断URL调用的状态值并处理 
xmlobj.send(null); //设置不发送给服务器任何数据 
return false;
} 

function StatHandler() //用于处理状态的函数 
{ 
if(xmlobj.readyState == 4 && xmlobj.status == 200) //如果URL成功访问则输出网页 
{ if(xmlobj.responseText==1){return false;}

document.getElementById("msg3").innerHTML = xmlobj.responseText;

return true;


} 
} 

