日期:2014-05-16  浏览次数:20656 次

ajax 返回数据乱码问题
发送前
JScript code
function fun_PolicyAPI()
                                            {
                                                var ajax = new AjaxPro("fun_PolicyAPI");
                                                var url = '/SYSPriceParity/YEEGO/Identity.asp?Spnrcode=<%= rs("of_pnr") %>&Bpnrcode=<%= rs("of_Bpnr") %>';
                                                ajax.Get(url);
                                            }

服务处理
JScript code
// JavaScript Document
//AjaxPro
// 声明 var objectname = new AjaxPro(div,value)
//参数 --[div]-->要显示数据的标签;[value]-->POST方法中要传递的值;[httpurl]-->AJAX指向的后台页面路径
//使用时声明对象后,直接可以用对象的方法,Get方法用于URL传值,Post方法用于提交数据

function AjaxPro(div)
{
    var XMLhttp=init();
    var Float = true;
    function init()
     {
         if (window.XMLHttpRequest)
            {
                return new XMLHttpRequest(); //firefox
            }
         else if (window.ActiveXObject) 
            {
                return new ActiveXObject("Microsoft.XMLHTTP"); //ie
            }
     }

     this.Process = function()     
     {
        ids = document.getElementById(div);        
        ids.innerHTML="正在处理数据,请稍后……";
        if(XMLhttp.readyState == 4)
        {
            if(XMLhttp.status == 200)
            {
                //alert(XMLhttp.responseText);
                ids.innerHTML=XMLhttp.responseText;
                innerHTML=setHeader("Charset","GB2312") ;
            }
        }
     }

     this.Load = function(method,HttpUrl,value)     
     {
        if(value==null){}
        XMLhttp.open(method,HttpUrl,Float);
        XMLhttp.onreadystatechange = this.Process;
        var https=null;
        if(method=="Post")
        {
            XMLhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            https = value;
        }
        XMLhttp.send(https);
     }
    
     this.Get = function(HttpUrl)     
     {
       this.Load("Get",HttpUrl);
     }
    
     this.Post = function(HttpUrl,value)     
     {
       this.Load("Post",HttpUrl,value);
     }
}




------解决方案--------------------
编码要一致。。不然就做下编码处理
------解决方案--------------------
AJAX 提交方式 改为post 试试