Architecture of JSON Mashups
Flow of JSON mashups that use Dynamic Script method goes as follows:
- The flow of the process starts with the browser sending request to the server by using HTTP GET.
- The Web Server responds with a page that includes the following couple of important JavaScript functions:
- A parsing function that expects JavaScript objects to be parameters.
- The Dynamic Script method is the core of the initiation script through which a new script tag is added to the page, specifying the source for that script tag to be the Uniform Resource Locator (URL) at some partner site.
- The source code for the new script tag gets loaded by the browser.
- Amazon receives an HTTP Get request sent from the browser using the loaded script.
- A JavaScript object, after being serialized into a JSON Object, is served by the partner site.
- A function call to the render function wraps the JSON script, and the JavaScript entirely becomes the content for the script tag.
- The new piece of JavaScript is tried for execution by the browser, which calls the render method from step 3.
- The server invokes the render method and evaluates the JSON script, which is converted into a JavaScript object. The data contained in the render method is pushed into the page after the render method, which uses the new JavaScript object in its execution.