I'm having problems collecting json values ββfrom a url in my application. When I try to get them, an error message is displayed on the console indicating that the origin is not allowed using the access-allow-allow-origin permission.
I did a little research and found out that the response headers should be set in Access-Control-Allow-Origin: *
How can I do this using pure javascript? No jquery or any other library.
This is my current code:
<script type="text/javascript"> var xmlHttp = null; xmlHttp = new XMLHttpRequest(); xmlHttp.open( "GET", "http://example.com/id=69", false ); xmlHttp.send( null ); console.log("JSON values from URL: "); console.log(xmlHttp.responseText); </script>
source share