In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use ajax in jQuery, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
How ajax is used
Type: default value: "GET"). Request method ("POST" or "GET"), default is "GET"
Url: default value: current page address. The address from which the request was sent.
Data: data sent to the server. Will be automatically converted to the request string format. The GET request will be appended to the URL. Must be in Key/Value format
ContentType: the type of content encoding when sending information to the server.
DataType: the type of data expected to be returned by the server. If not specified, jQuery will automatically judge intelligently based on the MIME information of the HTTP package
Success: the callback function after a successful request. Parameters: data returned by the server and processed according to the dataType parameter; a string describing the status.
1. Pass the specified parameter $.ajax ({
Type: 'post'
Url:'/ operate/getNewsBynew_id'
Data: {"new_id": data.new_id}
Success: function (data) {
}
); 2. Pass the json object $.ajax ({
Type: 'post'
Url:'/ news/addnews'
ContentType: "application/json; charset=utf-8"
Data: JSON.stringify (data.field)
Success: function (data) {
Location.href= "/ gover_index_1.html"
}
}
); 3. The background accepts data processing and returns the result @ PostMapping ("/ addnews")
Public News addNews (@ RequestBody News news) {
News.setTime (new Date ())
NewsService.insertNews (news)
Return news
} @ PostMapping ("/ getNewsBynew_id")
Public NewsAll getNews (Integer new_id) {
NewsAll newsAll=newsService.getNewsBynew_id (new_id)
System.out.println (newsAll.getS_times () + "+ newsAll.getTitle ())
Return newsAll
} Thank you for reading this article carefully. I hope the article "how to use ajax in jQuery" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.