ajax亂碼有關問題

來源:互聯網
上載者:User
ajax亂碼問題
參考一個ajax分頁的代碼,由於要串連sql server2000,把原代碼的utf8改為gb2312,結果點擊上一頁下一頁出現亂碼,資料庫已經預設是gb2312_chinese_ci了
代碼如下:

php代碼:
PHP code
PHP+ajax分頁示範".$total."條記錄 現在是第 ".$page." 頁 ";if($page<=1)$pagenav.="首頁 ";else$pagenav.="首頁 ";if($prepage)$pagenav.="上一頁 ";else$pagenav.="上一頁 ";if($nextpage)$pagenav.="下一頁 ";else$pagenav.="下一頁 ";if($pagenum)$pagenav.="尾頁 ";else$pagenav.="尾頁 ";$pagenav.="共".$pagenum."頁";if($page>$pagenum){    echo "error:沒有此頁".$page;    exit();}?>
  
使用者名稱 使用者密碼
$pagenav

";?>


js代碼
JScript code
var http_request=false;  function send_request(url){//初始化,指定處理函數,發送請求的函數    http_request=false;    //開始初始化XMLHttpRequest對象    if(window.XMLHttpRequest){//Mozilla瀏覽器     http_request=new XMLHttpRequest();     if(http_request.overrideMimeType){//設定MIME類別       http_request.overrideMimeType("text/xml");     }    }    else if(window.ActiveXObject){//IE瀏覽器     try{      http_request=new ActiveXObject("Msxml2.XMLHttp");     }catch(e){      try{      http_request=new ActiveXobject("Microsoft.XMLHttp");      }catch(e){}     }    }    if(!http_request){//異常,建立對象執行個體失敗     window.alert("建立XMLHttp對象失敗!");     return false;    }    http_request.onreadystatechange=processrequest;    //確定發送請求方式,URL,及是否同步執行下段代碼    http_request.open("GET",url,true);    http_request.send(null);  }  //處理返回資訊的函數  function processrequest(){   if(http_request.readyState==4){//判斷對象狀態     if(http_request.status==200){//資訊已成功返回,開始處理資訊      document.getElementById(reobj).innerHTML=http_request.responseText;     }     else{//頁面不正常      alert("您所請求的頁面不正常!");     }   }  }  function dopage(obj,url){   document.getElementById(obj).innerHTML="正在讀取資料...";   reobj = obj;   send_request(url);   }
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.