In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article "js object in jQuery, how to create json and ajax", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to create js objects, json and ajax in jQuery" article.
Js object
There are two ways to create js objects:
1. Create through new Object:
Var p1 = new Object (); / / set properties and methods p1.name = "Zhang San"; p1.age = 13th p1.study = function () {console.log (p1.name + "Learning, Sunflower Treasure Book");} / / call properties and methods console.log (p1.name); console.log (p1.age); p1.study ()
two。 To create by literal quantity (direct quantity):
Var p2 = {name: "Li Si", age:14, eat:function () {onsole.log (this.name + "eating garlic and durian");} console.log (p2.name); console.log (p2.age); p2.eat (); json
A data format that expresses js objects, is a string of strings, in the form of key-value pairs, the key needs to be in double quotes, and the value cannot be a method function, undefined, and null.
1.json to js object: JSON.parse ()
2.js object to json:JSON.stringify ()
Ajax
The purpose of ajax technology is to enable javascript to send http requests, communicate with the background, and obtain data and information. The principle of ajax technology is to instantiate a xmlhttp object and use it to communicate with the background. The process of ajax communication does not affect the execution of subsequent javascript, thus achieving asynchronism.
Ajax can achieve local refresh, also known as no refresh, no refresh refers to the entire page does not refresh, only partial refresh, ajax can send http requests, not through the browser's address bar, so the page as a whole will not refresh, ajax access to the background data, update the part of the page display data, to achieve a local refresh.
Common parameters:
Parameter describes the url request address type request method. By default, the data type returned by GETdataType is the data sent to the server by data. The callback function success after success, whether the callback function async after error failure is synchronous, and the default true async.
For example (displaying data to a page through an interface):
$.ajax ({url:'/index_data', type:'get', dataType:'json', success:function (dat) {/ / console.log (dat); var aList = dat; var sTr = 'serial number stock symbol referred to as up-and-down turnover rate latest price (yuan) early high date add optional'; for (var iDeposit I)
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.