AJAX-Tips Tutorials
AJAX-TipsCustomizing JSON Response
JSON is a very useful output for JavaScript. As an output that is specifically built for the same programming language, it is expected that it could work without any problem with JavaScript and Ajax based applications.
Although there is still browser incompatibilities expected from JavaScript and Ajax based applications, it should be expected that almost any function by JavaScript especially on DOM could be well received by JSON. With the compatibility provided by JSON, the options are almost endless when they are properly developed with JavaScript. Ease of user interaction and even increased security could be expected if they were just done right.
But the interaction with JavaScript and JSON changes greatly when your application needs to call data from another website. This is often practiced by developers since the interaction between websites eases the need for massive storage and processing capability on the server. The just have to call the website for the specific data and it could be used in another website.
However, developers cannot just get them at will and change them according to their needs. Even if they did have the permission from the webmaster from another site, they cannot bend the JSON output so that it could fit in their website.
Factors that Prohibit Changes on JSON
• Server Incompatibility – The data you receive when calling in JSON is not something processed through the website. They are in fact, directly coming from the server. Since they are from the server, they are raw data that could be used in the application. They cannot however be changed since they will be provided as is and interaction from another server to another website is greatly controlled for security purposes.
• API Based – One of the easiest ways to share data from another server and/or website is to use API. You can develop an API so that it could properly interact with other websites and process the data requests. However, this will only be possible if the API that you have in your website is almost the same or would have the same components with another API. This is very difficult to achieve especially if the developer from the other site is not so willing to share.
The Workaround
Although the server and API on the other website would block your chances of full interaction with another JSON, there is a possible workaround.
Instead of full interaction with JSON once you receive it from another online source, do not interact with the data directly. Instead of letting the raw data display on the client side, place it somewhere where you can retrieve them later.
To place it bluntly, you need to store the data in your end before you can fully customize the results. You need to make the data “your own” first before you can change them. It will require additional processing in your end. But if you really wanted to have the data and make some small changes on it, you need to create those steps. It is basically for your security as well as the other website’s protection.
Sponsored Links
