php ajax 分頁一

來源:互聯網
上載者:User

ajax 分頁用的是在用戶端分析資料,然後再發給php檔案進行處理,返回給用戶端處理理,思路就是這樣的.

這裡用到了三個檔案js檔案和一個php檔案:cookie.js page.js proptype.js result.php檔案,我們一一來看每個檔案的內容吧.

先看cookie.js代碼:

// JavaScript Document
function SetCookie (name,value,x_expires,x_path,x_domain,x_secure){  //設定一個Cookie值函數
//alert(name)
  var argv = SetCookie.arguments;
  //alert(this.argv);
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? x_expires : null;
  var path = (argc > 3) ? x_path : null;
  var domain = (argc > 4) ? x_domain : null;
  var secure = (argc > 5) ? x_secure : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) + 
  ((domain == null) ? "" : ("; domain=" + domain)) +   
  ((secure == true) ? "; secure" : "");
}
function GetCookie (name) {     //讀取指定名稱的cookie值函數
// alert(document.cookie)
  var arg = name + "="; 
  var alen = arg.length; 
  var clen = document.cookie.length;
  var i = 0; 
  while (i < clen)
  {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(";", i);
    if (i == -1) break;
    i+=2;
  }
  return null;
}
function getCookieVal (offset) {  
  var endstr = document.cookie.indexOf (";", offset); 
  if (endstr == -1)   
    endstr = document.cookie.length; 
  return unescape(document.cookie.substring(offset, endstr));
}
function DeleteCookie (name) {   //刪除Cookie值函數
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie (name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

這個檔案主是要處理cookie

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.