Table of Contents
jquery实现$.ajax的分页
Home php教程 php手册 ajax完美实现两个网页 分页功能的实例代码

ajax完美实现两个网页 分页功能的实例代码

Jun 13, 2016 am 11:53 AM
ajax meta code Pagination Function copy Perfect Example accomplish of Web page front page

分页的首页

复制代码 代码如下:



武侠小说分页



<script><BR>var page='';<BR> function init(page){<BR> document.getElementById("tables").innerHTML='';<BR> var xhr;<BR> if(window.XMLHttpRequest){<BR> xhr = new XMLHttpRequest();<BR>}else if(window.ActiveXObject){<BR> xhr =new ActiveXObject("Microsoft.XMLHTTP")<BR>}<BR>var url="fenye.php";<BR> xhr.open("POST",url,true);<BR> xhr.onreadystatechange=callback;<BR> xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");<BR> if(page){<BR> xhr.send("page="+page);<BR> }<BR> else {xhr.send("page=1");}<BR> var content;<BR> function callback(){<BR> if(xhr.readyState==4){<BR> if(xhr.status==200){<BR> var json =eval('('+xhr.responseText+')');<BR> //alert(xhr.responseText);<BR> var fenye=json.str;<BR> // alert(fenye);<BR> document.getElementById('div').innerHTML=fenye;<BR> content="<th>ID<th>名称<th>作者<th>出版社<th>ISBN号<th>类型<th>价格";<BR> for(var i=0;i<json.info.length;i++){<BR> content+="<tr><td>"+json.info[i].id+"<td>"+json.info[i].name+"<td>"+json.info[i].author+"<td>"+json.info[i].publisher+"<td>"+json.info[i].isbn+"<td>"+json.info[i].type+"<td>"+json.info[i].price+"";<BR> document.getElementById("tables").innerHTML=content;<BR> }<BR> // alert(fenye);<BR> }<BR> }<BR> }<BR> }<br><br></script>



 

jquery实现$.ajax的分页




ID 名称 作者 出版社 ISBN号 类型 价格


 


 

 

 





 

分页的php精华代码

复制代码 代码如下:


    //命令模型层处理数据
  $link=mysql_connect('localhost','root','') or die("失败");
  mysql_select_db('books',$link) or die("连接数据库出错了!");
  //每页显示记录数
  $pagesize = 2;
  //求出总的记录数
  $sql = "select count(*) as total_rows from books";
  $result = mysql_query($sql);
  $total_rows = mysql_fetch_array($result);
  //求总共的页码数
  $pages = ceil($total_rows[0]/$pagesize);
  //当前第几页
  $page = $_POST['page'];
  $strtext = "当前第".$page."页"."总共".$pages."页"."共".$total_rows[0]."记录";
  //var_dump($str);
  //接下来,我要根据当前点击的页码求出对应的数据
  $offset = $pagesize*($page-1);
  $sql = "select * from books limit $offset,$pagesize";
  mysql_query("set names utf8");
        $res=mysql_query($sql);

   $rows=array();
  while($row=mysql_fetch_assoc($res)){
    $rows[]=$row;
   }
  $pageInfo = $rows;
  //echo json_encode($pageInfo);
  //var_dump($pageInfo);
  //将获得数据链接,后返回
  $first=1;
  $prev=$page-1;
  $next=$page+1;
  $last=$pages;

  //命令视图层显示数据
      $first_a = "ajax完美实现两个网页 分页功能的实例代码";
  if($page>1){
   $prev_a = "ajax完美实现两个网页 分页功能的实例代码";
  }
  if($page   $next_a = "ajax完美实现两个网页 分页功能的实例代码";
  }
  $last_a = "ajax完美实现两个网页 分页功能的实例代码";
  @$str = $strtext.$first_a.$prev_a.$next_a.$last_a;
  //var_dump($str);
  $info = array('str'=>$str,'info'=>$pageInfo);
  echo json_encode($info);

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

New affordable Meta Quest 3S VR headset appears on FCC, suggesting imminent launch New affordable Meta Quest 3S VR headset appears on FCC, suggesting imminent launch Sep 04, 2024 am 06:51 AM

The Meta Connect 2024event is set for September 25 to 26, and in this event, the company is expected to unveil a new affordable virtual reality headset. Rumored to be the Meta Quest 3S, the VR headset has seemingly appeared on FCC listing. This sugge

The first open source model to surpass GPT4o level! Llama 3.1 leaked: 405 billion parameters, download links and model cards are available The first open source model to surpass GPT4o level! Llama 3.1 leaked: 405 billion parameters, download links and model cards are available Jul 23, 2024 pm 08:51 PM

Get your GPU ready! Llama3.1 finally appeared, but the source is not Meta official. Today, the leaked news of the new Llama large model went viral on Reddit. In addition to the basic model, it also includes benchmark results of 8B, 70B and the maximum parameter of 405B. The figure below shows the comparison results of each version of Llama3.1 with OpenAIGPT-4o and Llama38B/70B. It can be seen that even the 70B version exceeds GPT-4o on multiple benchmarks. Image source: https://x.com/mattshumer_/status/1815444612414087294 Obviously, version 3.1 of 8B and 70

Six quick ways to experience the newly released Llama 3! Six quick ways to experience the newly released Llama 3! Apr 19, 2024 pm 12:16 PM

Last night Meta released the Llama38B and 70B models. The Llama3 instruction-tuned model is fine-tuned and optimized for dialogue/chat use cases and outperforms many existing open source chat models in common benchmarks. For example, Gemma7B and Mistral7B. The Llama+3 model improves data and scale and reaches new heights. It was trained on more than 15T tokens of data on two custom 24K GPU clusters recently released by Meta. This training dataset is 7 times larger than Llama2 and contains 4 times more code. This brings the capability of the Llama model to the current highest level, which supports text lengths of more than 8K, twice that of Llama2. under

The strongest model Llama 3.1 405B is officially released, Zuckerberg: Open source leads a new era The strongest model Llama 3.1 405B is officially released, Zuckerberg: Open source leads a new era Jul 24, 2024 pm 08:23 PM

Just now, the long-awaited Llama 3.1 has been officially released! Meta officially issued a voice that "open source leads a new era." In the official blog, Meta said: "Until today, open source large language models have mostly lagged behind closed models in terms of functionality and performance. Now, we are ushering in a new era led by open source. We publicly released MetaLlama3.1405B, which we believe It is the largest and most powerful open source basic model in the world. To date, the total downloads of all Llama versions have exceeded 300 million times, and we have just begun.” Meta founder and CEO Zuckerberg also wrote an article. Long article "OpenSourceAIIsthePathForward",

Llama3 comes suddenly! The open source community is boiling again: the era of free access to GPT4-level models has arrived Llama3 comes suddenly! The open source community is boiling again: the era of free access to GPT4-level models has arrived Apr 19, 2024 pm 12:43 PM

Llama3 is here! Just now, Meta’s official website was updated and the official announced Llama 38 billion and 70 billion parameter versions. And it is an open source SOTA after its launch: Meta official data shows that the Llama38B and 70B versions surpass all opponents in their respective parameter scales. The 8B model outperforms Gemma7B and Mistral7BInstruct on many benchmarks such as MMLU, GPQA, and HumanEval. The 70B model has surpassed the popular closed-source fried chicken Claude3Sonnet, and has gone back and forth with Google's GeminiPro1.5. As soon as the Huggingface link came out, the open source community became excited again. The sharp-eyed blind students also discovered immediately

Understanding VSCode: What is this tool used for? Understanding VSCode: What is this tool used for? Mar 25, 2024 pm 03:06 PM

&quot;Understanding VSCode: What is this tool used for?&quot; 》As a programmer, whether you are a beginner or an experienced developer, you cannot do without the use of code editing tools. Among many editing tools, Visual Studio Code (VSCode for short) is very popular among developers as an open source, lightweight, and powerful code editor. So, what exactly is VSCode used for? This article will delve into the functions and uses of VSCode and provide specific code examples to help readers

Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Tsinghua University and Zhipu AI open source GLM-4: launching a new revolution in natural language processing Jun 12, 2024 pm 08:38 PM

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

Analyst discusses launch pricing for rumoured Meta Quest 3S VR headset Analyst discusses launch pricing for rumoured Meta Quest 3S VR headset Aug 27, 2024 pm 09:35 PM

Over a year has now passed from Meta's initial release of the Quest 3 (curr. $499.99 on Amazon). Since then, Apple has shipped the considerably more expensive Vision Pro, while Byte Dance has now unveiled the Pico 4 Ultra in China. However, there is

See all articles