PHP generates an array and then transmits it to js. php generates an array js

Source: Internet
Author: User

PHP generates an array and then transmits it to js. php generates an array js

<Script type = "text/javascript"> var slist = '<? Php echo urlencode (json_encode ($ data ['arr']);?> '; Var list = eval (decodeURIComponent (slist); drawGpsMap (list); </script>

How to pass the php array value to the javascript array?

Cannot be passed directly, but php array values can be dynamically called during page loading using js ajax.
Or assign the array value processed by php to the html den control first, and then use js Code to call the value of hidden.
In addition, I think it is better to use php to generate a. js file if your data does not change frequently. This file defines the array and then file the file.

How to pass the values in the PHP array to JS

<Script type = "text/javascript"> flowplayer ("player2", "./templates/flowplayer-3.2.15.swf", {clip: {url: "<? Php echo $ row ['address'];?> ", I want to replace this address with the Database Value autoPlay: false, autoBuffering: true}); </script> what do you mean?


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.