Using Json to realize data exchange between PHP and JavaScript
JSON (JavaScript) is a lightweight data interchange format.
Jane, either XML or JSON, is a transfer station to facilitate the interaction of data between the client and the server side, especially for object type data, such as the most common array.
will send the array from PHP to JavaScript, and send the array from JavaScript to the PHP example, the example is simple and the concept can be understood. No matter from PHP to JavaScript or JavaScript to PHP, JSON will flatten the object to be a string before transmitting.
PHP passes to JavaScript value
PHP file json.php
[code].Lt;? Php
$arr = array. 'http://www.nowamagic.net',
)
;
$json_string = json_encode ($arr);
echo.Quot; getProfile ($json_string); .quot; nick.quot;.Quot; Gonn.quot;.Quot; contact.quot; {.quot; email.quot;.Quot; gonnsai@163.com.quot;.Quot; website.quot; Number.