Ajax
AJAX = Asynchronous JavaScript and XML (asynchronous JavaScript and XML).
AJAX is not a new programming language, but a new way of using existing standards.
AJAX is the art of exchanging data with the server and updating parts of the Web page without reloading the entire page.
What is JSON?
The full name of JSON is the JavaScript Object notation (JavaScript objects notation), which is based on the literal amount of JavaScript objects, and if you look at it from the eye, the data in JSON is stored in curly braces--{}, If further analysis is used, JSON is a data interchange format. Within JSON, the format is arranged by name: value, such as the following Json1, which is a JSON object.
var json1={"name": "Li Ming", "Age": "Sex": "Boy"}
What is a JSON string?
To put double quotes (or single quotes) on both sides of the JSON, in order to avoid conflicting with the inner double quotes, we place a single quotation mark over the outside, which is a JSON string, as in the following Json2
var json2= ' {' name ': "Li Ming", "Age": "Sex": "Boy"} '
2. In our data supply page, output our JSON, we still put the data to provide the page called tigong.php
The code is as follows:
<?php
Header ("Content-type:text/html;charset=utf-8");
Echo ' {' name ': "Dawn", "Age": "A", "Sex": "Male"} ';
? >
3. Receive data on our front-end page and use the Eval method to parse the JSON string into a JSON object and iterate it out with a for loop. We call this page a testjsonevel.html.
Evel there are no compatibility issues, but there are security vulnerabilities.
Effect as shown:
4. Using the Json.parse method to parse the JSON string as a JSON object, we call this page testjsonparse.html, which is as follows
Json.parse There are no security vulnerabilities, but there are compatibility, IE8, and the following are not supported.
Effect as shown
The above is a small set to introduce the use of native AJAX processing JSON string method, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!