Complete code by page using ajax and Douban search results.
Use the watercress api to obtain the paging result. The results are the same as those obtained from the background database. The difference is that you cannot know the number of pages in advance. Although the total number of pages can be obtained through the request api, because ajax is asynchronous, it makes no sense to give the total number of pages at the beginning of the page. I used a Fixed Total number of pages 65 (the total number of pages returned by searching javascript books ). Therefore, other books are not 65 pages and may contain multiple pages or fewer pages. This is not a bug.
Features
1. You do not need to contact the backend for the whole process. The front-end can be independent (I haven't found a complete example for a long time ).
2. Use pagination of bootstrap to create the page number and panel to create the panel for storing the result.
The Code is as follows:
<! DOCTYPE html>
Reference
Http://bbs.csdn.net/topics/390734775? The logic processing section in page = 1 uses the code here, but it is modified.
Effect display
Https://yuwanlin.github.io/general/%E5%88%86%E9%A1%B5/%E7%BB%93%E5%90%88%E8%B1%86%E7%93%A3%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E8%BF%9B%E8%A1%8C%E5%88%86%E9%A1%B5.html