Home >Backend Development >PHP Tutorial >ajax3—php(29)

ajax3—php(29)

WBOY
WBOYOriginal
2016-08-08 09:23:501009browse

1. Application of json in Ajax

For the processing of large batches of data:

1) } To simulate an unordered collection of attributes

1. About json in php

Currently, most ajax programs use json objects as data transfer methods, so many languages ​​​​have built-in support for json Object support. In php, there are two functions for encoding and decoding json

l string json_encode (mixed $value)

Generate a string in json format

l mixed json_decode (string $json [, bool])

Parse json

The second parameter indicates whether to parse into an array or an object. The default is false, which means parsing into an object

1) json_encode

If you want to get data in json format, you must first get an array or Object

2) json_decode

3) json_decode

Json currently only supports utf-8 format

3, Ajax uses json

Example 1: Return two using json Four arithmetic operations of numbers

Server code:

Example 2: Return multiple pieces of data from the server

Ajax program:

Php program:

The above has introduced ajax3-php (29), including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn