On data exchange, cache and synchronization of JSON

JSON lightweight data exchange format

Compared with XML, JSON has faster parsing speed and smaller documents.

JSON format

{property name: property value, property name: property value,...}

The type of attribute name can be string, number, Boolean, null, object, and the attribute name must be enclosed in double quotation marks. If the attribute value is a string, it must also be enclosed in double quotation marks.

JSON represents an array

Format: [value, value, value], where value can be basic data type, object type and array type

transformation

1. Use the native function of javascript: Eval (), but this method is dangerous and should be used with caution.

2. Use the parse () method provided by the native object JSON. If this object is invalid, your browser version is too low!!!

3. Use JSON JS file is a method to add a string.

Convert JSON object to JSON string

Use the API provided by JSON official: jsonobject and the method provided by jsonarray

Cache issues involved in Ajax sending requests

==Note = =: when sending a request, the Ajax object provided by IE browser will first check whether it has accessed the address. If so, the browser will not send a request.

Different browsers treat caching mechanisms

Chrome continues to send request Firefox continues to send request IE browser will not send request

How to prevent the browser from sending requests because of caching?

Add a random number after the request address

Send post request

Some problems about synchronization

After sending the synchronization request, the browser must wait for the response from the server to arrive before continuing to operate in the page. When Ajax sends a synchronization request, the browser will lock the current page.

Test code

Operation results:

summary

The above is all about the data exchange, caching and synchronization of JSON. I hope it will be helpful to you. Interested friends can continue to refer to other related topics on this site. If there are deficiencies, please leave a message to point out. Thank you for your support!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>