thinkphp example _php instance of menu and pagination based on AJAX implementation

Source: Internet
Author: User
Tags php template

This article illustrates the thinkphp method of implementing menus and pagination based on Ajax. Share to everyone for your reference, specific as follows:

A category menu that is implemented using Ajax:

function GetID (ID) {
$.ajax ({
   URL: ' {: U ('/index/example ')} ',
   type: ' POST ',
   data: {id:id}
  }). Success (function (data) {
   $ ("#centent"). HTML (data);
  }


and use Ajax paging, this one is written on the Internet:

<script type= "Text/javascript" >
<!--
$ ("#page_show > A"). Click (function () {
  $ (' # Centent '). Append (' <span id= "lod" > Loading. </span> ');
  Gets the URL
  var _href = $ (this). attr (' HREF ');
  Load page
  $ ("#centent"). Load (_href, ', function () {
    $ ("#lod"). Remove ();
  });
  return false;
});
-->
</script>

There is nothing wrong with the menu content that was implemented before using post

$.post (URL, function (data) {
 $ ('. Centent '). HTML (data);
});

However, when using AJAX implementations, you cannot get the correct results. Pagination cannot be completed.
In the final thoughts, type: "POST" to type: "Get",
Solve the problem. The Post method is also submitted by post, and Ajax starts with post, why not? Finally found or the reason for the URL, the two URLs are not the same.

More interested in thinkphp related content readers can view the site topics: "thinkphp Introductory Course", "thinkphp Common Methods Summary", "PHP operation Office Document Skills Summary (including word,excel,access,ppt)", " A summary of cookie usage in PHP, the basics of Smarty Templates tutorial and the PHP template technology summary.

I hope this article will help you with the PHP program design based on thinkphp framework.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.