質問編集履歴

1

変更

2019/02/11 09:07

投稿

Chandler_Bing
Chandler_Bing

スコア673

test CHANGED
File without changes
test CHANGED
@@ -95,3 +95,97 @@
95
95
  参考:サイト
96
96
 
97
97
  https://rimane-novels.net/php-for-js-945/
98
+
99
+
100
+
101
+ 「追記」
102
+
103
+
104
+
105
+ 回答ありがとうございます。現在のコードです
106
+
107
+ エラー
108
+
109
+ [Error] SyntaxError: Unexpected identifier 'word'. Expected '}' to end an object literal.
110
+
111
+ (anonymous関数) (sampke.php:23)
112
+
113
+ [Error] ReferenceError: Can't find variable: php
114
+
115
+ (anonymous関数) (showhotels.js:3)
116
+
117
+ j (jquery.min.js:2:26931)
118
+
119
+ fireWith (jquery.min.js:2:27740)
120
+
121
+ ready (jquery.min.js:2:29544)
122
+
123
+ I (jquery.min.js:2:29729)
124
+
125
+ ```PHP
126
+
127
+ <?php
128
+
129
+
130
+
131
+ $word = json_encode(['word' => 'おはよう'],JSON_HEX_QUOT | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS);
132
+
133
+
134
+
135
+ ?>
136
+
137
+ <!DOCTYPE html>
138
+
139
+ <html lang="en" dir="ltr">
140
+
141
+
142
+
143
+ <head>
144
+
145
+ <meta charset="utf-8">
146
+
147
+ <title>SeeHotels</title>
148
+
149
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
150
+
151
+ </head>
152
+
153
+
154
+
155
+ <body>
156
+
157
+ <header>
158
+
159
+ </header>
160
+
161
+
162
+
163
+ <main>
164
+
165
+ <p>今日はいい天気ですね</p>
166
+
167
+ </main>
168
+
169
+
170
+
171
+ <footer>
172
+
173
+ </footer>
174
+
175
+
176
+
177
+ </body>
178
+
179
+ <script>
180
+
181
+ var php = {word: "<?php echo $word; ?>"};
182
+
183
+ </script>
184
+
185
+ <script src="js/showhotels.js"></script>
186
+
187
+ </html>
188
+
189
+
190
+
191
+ ```