Passing Data from PHP to Javascript

preview_player
Показать описание
In this video tutorial I show you how you can pass data from PHP to Javascript. This can be helpful if you use PHP to load data from a database or from some XML and you need some of that data in JavaScript code you have on your homepage.

I, for example, do this in my gallery pages where I read image information from an XML file and then when the user clicks through the images I present different information based on the current image.

★☆★ my Github ★☆★

★☆★ my Landscape Photography Channel ★☆★

★☆★ Software I use (Affiliate Links) ★☆★

★☆★ homepage★☆★

Рекомендации по теме
Комментарии
Автор

Getting an error:- "Syntax Error: not a valid json"

indrajitmandal
Автор

Typically the embedded data is in its own, separate script tag of type="application/json".
That way JavaScript code in a separate static file (or bundle) can access it.

PeerReynders