質問編集履歴

1

エラーメッセージとソースコードを追加しました。

2017/08/23 08:43

投稿

sabamiso
sabamiso

スコア14

test CHANGED
File without changes
test CHANGED
@@ -22,6 +22,138 @@
22
22
 
23
23
 
24
24
 
25
+ Failed to load resource: the server responded with a status of 404 (Not Found) _answer.php
26
+
27
+
28
+
29
+ ###ソースコード
30
+
31
+ ```lang-html
32
+
33
+ <!DOCTYPE html>
34
+
35
+ <html lang="ja">
36
+
37
+ <head>
38
+
39
+ <meta charset="utf-8">
40
+
41
+ <title>Quiz</title>
42
+
43
+ <link rel="stylesheet" href="styles.css">
44
+
45
+ </head>
46
+
47
+ <body>
48
+
49
+ <div id="container">
50
+
51
+ <h1></h1>
52
+
53
+ <ul>
54
+
55
+ <li class="answer">○</li>
56
+
57
+ <li class="answer">×</li>
58
+
59
+ </ul>
60
+
61
+ <div id="btn" class="disabled">Next Question</div>
62
+
63
+ </div>
64
+
65
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
66
+
67
+ <script src="quiz.js"></script>
68
+
69
+ </body>
70
+
71
+ </html>
72
+
73
+
74
+
75
+ ```
76
+
77
+
78
+
79
+ ```lang-php
80
+
81
+ <?php
82
+
83
+
84
+
85
+ require_once(__DIR__ . '/config.php');
86
+
87
+ require_once(__DIR__ . '/Quiz.php');
88
+
89
+
90
+
91
+ $quiz = new MyApp\Quiz();
92
+
93
+ $correctAnswer = $quiz->checkAnswer();
94
+
95
+
96
+
97
+ header('Content-Type: application/json; charset=UTF-8');
98
+
99
+ echo json_encode([
100
+
101
+ 'correct_answer' => $correctAnswer
102
+
103
+ ]);
104
+
105
+ ```
106
+
107
+ ```lang-JavaScript
108
+
109
+ $(function() {
110
+
111
+ 'use strict';
112
+
113
+
114
+
115
+ $('.answer').on('click', function() {
116
+
117
+ var answer = null;
118
+
119
+ var $selected = $(this);
120
+
121
+ if('â—‹' == $selected.text()){
122
+
123
+ answer = 0;
124
+
125
+ }else {
126
+
127
+ answer = 1;
128
+
129
+ }
130
+
131
+
132
+
133
+ $.post('/_answer.php', {
134
+
135
+
136
+
137
+ }).done(function(res) {
138
+
139
+ alert(res.correct_answer);
140
+
141
+ });
142
+
143
+ });
144
+
145
+
146
+
147
+ });
148
+
149
+
150
+
151
+ ```
152
+
153
+
154
+
155
+
156
+
25
157
  ###試したこと
26
158
 
27
159
 
@@ -34,4 +166,6 @@
34
166
 
35
167
  ###補足情報(言語/FW/ツール等のバージョンなど)
36
168
 
169
+ Apache, nginx ともにphpの基本動作は確認できています。
170
+
37
171
  解決方法をよろしくお願いいたします。