Ajax使用Post方法传递数据

    function JugingData()
    {
            var xmlHttp;
            try
            {
                xmlHttp = new XMLHttpRequest();
            }
            catch(e)
            {
                try
                {
                    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e)
                {
                    try
                    {
                        xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
                    }
                    catch(e)
                    {
                        alert("您的浏览器不支持Ajax!");
                        return false;
                    }
                }
            }
            xmlHttp .open("post","JugeOutPutAvalable.aspx",true);
            xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xmlHttp .onreadystatechange = function()
            {
                if (xmlHttp.readyState == 4)
                {
   var strResult = xmlHttp .responseText;
                      alert(strResult);
                }
            }
            xmlHttp .send("Datas=大量的数据");
    }

 

 

本人具体也没研究过为什么要加上这句话(不加是不能使用的):

request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");

posted on 2010-06-17 13:49  冰危节奏  阅读(231)  评论(0)    收藏  举报

导航