This requires the use of JQuery, ASHX and Json to cooperate. An article has multiple comments, each of ten comments per page. Every time the user clicks on the next page, the next page will be automatically grabbed. This process can be carried out safely without refreshing.
Json format is actually similar to table format. In network transmission, it saves traffic than XML, and it is better integrated with JS and is easier to parse. A sample Json format is as follows:
{"Products":[
{"orderid":"11077","customerid":"RATTC"},
{"orderid":"11078","customerid":"RATT"}
],
" Img":[{"id":"12345","url"
:"image/1.jpg"}
]}
We can think of Products and Img as The name of a table. In the Products table, orderid and customerid are both fields of Products. 11077 and RATTC can be understood as the values of the corresponding fields. The same goes for the Img part. Therefore, there are two records for Products above, while there is only one record for Img.
So how do we parse out the corresponding tables, fields and values in JQuery?
In JQuery we can use:
var Products= Json.Products;
to filter the Products table. Next, we loop through Products to read the values:
$.each(Products, function(i, n) {
str = "
" n.orderid "ID" n.customerid "
";
});
$.each(Products, function(i, n) {} Products here is the table in our target Json data. i represents the order of records, starting from 0 (0 represents the first stroke, 1 represents the second stroke...), and n represents the value of the corresponding field. The reading of Img is also similar~~
Please correct me if there is anything inappropriate, thank you!