Simple patterns: PHP to JavaScript
You can pass data between the client and server in a number of ways. I like to mirror data structures between my server and client, so that I have the same basic data model available in both realms. There are a few ways to do this, including: Calling an API that returns JSON (or JSONP) Calling an API that returns some UI, which can include some JSON Getting an entire page that includes your data model in JSON Sending a client data is trivial in most dynamic languages, and PHP is no different. You return a response body with the result of a json_encode and your data model. The technique works just as well in APIs as it does in standard HTML templates: ...