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.