Display content of another website on my page using jquery without using iframe in Rails
Thanks guys @Rory McCrossan @Mohammed ElSayed This is how I enabled CORS settings in Rails 4 Inside my application_controller
after_filter :cors_set_access_control_headers
def cors_set_access_control_headers
headers['Access-Control-Allow-Origin'] = '*'
headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
headers['Access-Control-Request-Method'] = '*'
headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
end
the error message is not actually an error, it's by design so no one can load others content without proper permission.
you will need to enable CORS requests for the website that you are calling.
for IIS7:
consider the following snippet (web.config)
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
Apache server (.htaccess):
Header set Access-Control-Allow-Origin "*"
checkout this link for more information: http://enable-cors.org/server.html