In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you jQuery encapsulated ajax how to process requests for JSON data, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
The specific implementation code is as follows:
JavaScript code
{"data": [{"id": "1", "name": "Select A", "value": "A"}, {"id": "2", "name": "Select B", "value": "B"}, {"id": "3", "name": "Select C", "value": "C"}]}
Parse the above json data class in the success function of jquery
JavaScript code
Ajax ({type: "POST", url: "xxx.do", dataType: "json", / / specify the return type data: {xxx: "yyy"}, / / the parameter success passed to the background: function (data) {$.each (data, function (index,values) {/ / parses the Object array $.each (values,function (index2,value) {/ / traversing Object array corresponding to data, the value of each object is stored in value Index2 is represented as the number of objects / / data processing alert (value.name + "" + value.value) according to its own logic. / / TODO: logic});});}, error: function () {alert ("system problem");}})
Let's go on with an example.
This section shares a code example, which is the request processing of JSON data by ajax encapsulated by jQuery.
The code is relatively simple, for experienced personnel can skim, beginners can do a reference.
The code is as follows:
$(document) .ready (function () {$("# bt") .click (function () {$.ajax ({type: "get", dataType: "json", url: "demo/jQuery/ajax/txt/json.txt", success: function (msg) {var data = msg str= "; $.each (data,function (index, n) {str=str+ data [index] .webName +", "+ data [index] .url +", "+ data [index] .age +") }); $("# show") .html (str);}})}) above are all the contents of the article "how to process requests for JSON data in ajax encapsulated by jQuery". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.