質問編集履歴

1

誤字

2021/01/05 10:25

投稿

lemonediscream
lemonediscream

スコア27

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,31 @@
1
+ jsの★の部分のnの値を一番下のコードのstandard.blade.phpで値を受け取りたいです。
2
+
3
+ jsで以下のコードでstandard.blade.phpに値をセットをしております。
4
+
5
+ **$('#getresult').val(n);**
6
+
7
+ standard.blade.phpで
8
+
9
+ **<input type="hidden" name="getresult" id="getresult" value=""/>**
10
+
11
+ のvalueで値をセットできていると思って、
12
+
13
+ **<?php
14
+
15
+ if(isset($_POST[‘getresult’])){
16
+
17
+ $comment = $_POST[‘getresult’];
18
+
19
+ echo $comment;
20
+
21
+ }
22
+
23
+ ?>**
24
+
25
+ 上記のコードで確認しようと思ったのですが、**Use of undefined constant ‘getresult’ - assumed '‘getresult’'** のエラーがでます。
26
+
27
+ 改善方法をお願い致します。
28
+
1
29
  ```js
2
30
 
3
31
  $(document).ready(function () {
@@ -20,15 +48,7 @@
20
48
 
21
49
  'sceneId': _scenarioSelected,
22
50
 
23
- 'elements': _elements,
51
+ 'elements': _elements
24
-
25
- 'elementNames': _elementsName,
26
-
27
- 'headers':, _headers,
28
-
29
- 'catId': _catSelected,
30
-
31
- 'condAndOr': _condAndOrVal
32
52
 
33
53
  };
34
54
 
@@ -72,8 +92,12 @@
72
92
 
73
93
  var n = result.aaData;
74
94
 
95
+ //standard.blade.phpに値をセット
96
+
75
97
  $('#getresult').val(n);
76
98
 
99
+       //値を確認できています
100
+
77
101
  console.log(n[0]);
78
102
 
79
103
 
@@ -89,3 +113,103 @@
89
113
 
90
114
 
91
115
  ```
116
+
117
+ ```php
118
+
119
+ class ScenarioAjaxController extends Controller
120
+
121
+ {
122
+
123
+ public function getSearchResult(Request $request)
124
+
125
+ {
126
+
127
+ if (!$request->ajax()) {
128
+
129
+ return response()->json([],401);
130
+
131
+ }
132
+
133
+
134
+
135
+ $data = $this->getSearchData($request);
136
+
137
+
138
+
139
+ $response = array(
140
+
141
+ "aaData" => $data
142
+
143
+ );
144
+
145
+
146
+
147
+ echo json_encode($response);
148
+
149
+ }
150
+
151
+
152
+
153
+ }
154
+
155
+ ```
156
+
157
+ ```php
158
+
159
+ Route::post('ajax/searchResult', 'Ajax\scenarioAjaxController@getSearchResult');
160
+
161
+ ```
162
+
163
+ ```php
164
+
165
+ //standard.blade.php
166
+
167
+ <!doctype html>
168
+
169
+ <html lang="jp" class="no-js">
170
+
171
+
172
+
173
+ <head>
174
+
175
+
176
+
177
+ @include('css_js_part',['activePage'=>'standard'])
178
+
179
+
180
+
181
+ </head>
182
+
183
+ <body>
184
+
185
+ <div class= "getResult">
186
+
187
+ <form name="getresult" id="getresult" method="post">
188
+
189
+ @csrf
190
+
191
+ <input type="hidden" name="getresult" id="getresult" value=""/>
192
+
193
+ </form>
194
+
195
+ </div>
196
+
197
+ </body>
198
+
199
+
200
+
201
+ </html>
202
+
203
+ //<?php
204
+
205
+ //if(isset($_POST[‘getresult’])){
206
+
207
+ // $comment = $_POST[‘getresult’];
208
+
209
+ //echo $comment;
210
+
211
+ //}
212
+
213
+ ?>
214
+
215
+ ```