Re: to fill a select with json javascript from arrays [message #175079 is a reply to message #175072] |
Thu, 11 August 2011 00:12 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
On Wed, 10 Aug 2011 14:13:10 +0200, nawfer wrote:
> in JSON/javascript ....
If you're trying to create a json string from PHP array data to send to a
javascript application:
http://uk2.php.net/manual/en/function.json-encode.php
If you're trying to create a PHP array or object from json data that has
been created by a javascript application:
http://uk2.php.net/manual/en/function.json-decode.php
if you're trying to create json data with javascript, or create a
javascript object from json data, try asking in a javascript newsgroup or
forum, not a php one.
If you're trying to send a string of json encoded data in response to a
client side ajax style request:
<?php
// process the request
// create the data string to send
echo $json_encoded_string;
?>
Note that generally you don't want to include any other output, and
specifically no html tags.
Rgds
Denis McMahon
|
|
|