Cross-Domain JavaScript With Simple PHP Proxy
28
Jan
// php the_time('Y') ?>
Using JavaScript, it is possible to load HTML, XML or JSON data with XMLHttpRequest.
However cross-domain JavaScript requests (reaching remote pages) are not possible due to browser security limitations except JSONP-formatted JSON data.
Simple PHP Proxy is a PHP script which aims to fill this gap by creating a layer between your JavaScript code and the remote domain to get data in HTML, XML or JSON formats.
Some features of Simple PHP Proxy:
- requested URLs can be white-listed & validated against a regex.
- optionally forward client cookies / SID to the remote server.
- optionally forward configurable User Agent to the remote server.
- requests can use either GET or POST request methods.
- remote data can be delivered as-is with all remote headers intact.
- remote data can be wrapped in a JSON/P structure that includes status codes & remote headers.
- if using JSON/P & remote data is valid JSON, it will be merged into the resulting data object.
There is also a demo which you can request any URL.
Requirements: PHP
Website: http://benalman.com/projects/php-simple-proxy/
Demo: http://benalman.com/code/projects/php-simple-proxy/e...
Website: http://benalman.com/projects/php-simple-proxy/
Demo: http://benalman.com/code/projects/php-simple-proxy/e...
- Tags:
JSON JSONP Php XML
- Filed under: Extras, GPL License, MIT License, Tools
- 1 Comment
Related Posts


















One Response for "Cross-Domain JavaScript With Simple PHP Proxy"
Must use PHP cURL. I like the thought of returning JSON, it has a very light payload in transit.