我有一個功能規格,作爲頁面加載的一部分。 我打了一個本地的URL來獲取更多的數據。Rails水豚功能規格否'Access-Control-Allow-Origin'
即使用http://fullcalendar.io/ 它加載它是通過AJAX
events: {
url: 'calendar_events.json',
type: 'GET',
error: function(response) {
...
}},
我越來越
XMLHttpRequest cannot load http://localhost:3000/calendar_events.json?start=2014-01-20&end=2014-01-27. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status code 404.
不完全知道如何解決事件。我試着加入
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Methods'] = 'POST, PUT, DELETE, GET, OPTIONS'
response.headers['Access-Control-Request-Method'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, Authorization'
去我的應用程序控制器上的before_filter只是爲了看,但仍然得到同樣的問題。
注:我用的水豚,WebKit的
http://stackoverflow.com/a/6120260/3274024你可以檢查出來,也許這是什麼錯了請求。 – jfornoff
真的不想把它改成jsonp – dboyd68
也許跨域觸發器就夠了。不知道我是否明白爲什麼你要訪問本地網址,是否可以不在服務器端立即渲染它? – jfornoff