teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの追加

2016/08/04 14:16

投稿

yu01
yu01

スコア15

title CHANGED
File without changes
body CHANGED
@@ -2,9 +2,33 @@
2
2
 
3
3
  getリクエストしてとあるWebAPIのリソースを取得したいのですが
4
4
 
5
- XMLHttpRequest cannot load https://www.abc.jp/admin/api_json/getPlanList?&username=hogehoge&password=hogehoge&did=16&sid=29&ymd=20160805. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:8100' is therefore not allowed access.
5
+ XMLHttpRequest cannot load https://www.abc.jp/api/getPlanList?&username=hogehoge&password=hogehoge&did=16&sid=29&ymd=20160805. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://0.0.0.0:8100' is therefore not allowed access.
6
6
 
7
7
  といったエラーでてしまっています。
8
8
  解決方法をご教示頂けると幸いです。
9
9
 
10
- 何卒よろしくお願いいたしますm(_ _)m
10
+ 何卒よろしくお願いいたしますm(_ _)m
11
+
12
+ `$scope.search = function() {
13
+
14
+ var headers = {
15
+ 'Access-Control-Allow-Origin' : '*',
16
+ 'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT',
17
+ 'Content-Type': 'application/json',
18
+ 'Accept': 'application/json'
19
+ };
20
+
21
+
22
+
23
+ $http({
24
+ method: 'GET',
25
+ url: "https://www.abc.jp/api/getPlanList?&username=hogehoge&password=hogehoge&did=16&sid=29&ymd=20160805",
26
+ headers:headers
27
+ }).then(function successCallback(response) {
28
+ // ok
29
+
30
+ }, function errorCallback(response) {
31
+ console.log(response);
32
+ });
33
+
34
+ `