Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Javascript AJAX Code to realize Book Management

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to share with you how to use Javascript AJAX code to achieve book management related knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you can get something after reading this article, let's take a look at it.

1. Interface documentation

2. Code structure Document body {margin: 20px 20px } Book Information title author Publishing House Add Id title author Publishing House operation / / render book confidence to the table $(function () { / / initiate an ajax request to get book list information getBookList () Function getBookList () {$.get ('http://www.liulongbin.top:3006/api/getbooks', function (res) {if (res.status! = = 200) return alert (' failed to get book information!') / / define an empty array to store book information var row = [] / / the information obtained by traversing is added to the row array $.each (res.data, function (I) Item) {row.push (`${item.id} ${item.bookname} ${item.author} ${item.publisher} Delete `)}) / / render the array data to the page $('# tb') .empty () .append (row.join ('') )})} / / Delete book information $('tbody') .on (' click' '# del', function () {var id = $(this) .attr (' data-id') Get ('http://www.liulongbin.top:3006/api/delbook', {id: id}, function (res) {if (res.status! = = 200) return alert (' failed to delete the book!') GetBookList () )})}) / / add books $('# btnSend'). On ('click', function () {var bookName = $(' # bookName'). Val (). Trim () var author = $('# author'). Val (). Trim () var ippublisher = $('# ippublisher'). Trim () if (bookName.length

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report