質問編集履歴
3
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,13 +64,15 @@
|
|
64
64
|
|
65
65
|
if(isset($_POST["a"])){
|
66
66
|
|
67
|
-
$j =
|
67
|
+
$j = $_POST["a"];
|
68
|
+
|
69
|
+
var_dump($j);//しっかり配列に入る
|
68
70
|
|
69
71
|
$c=count($j);
|
70
72
|
|
71
73
|
for($i=0;$i<$c;$i++){
|
72
74
|
|
73
|
-
echo $j[$i];//abcを出力
|
75
|
+
echo $j[$i];//配列に入ってるが、abcを出力されない
|
74
76
|
|
75
77
|
}
|
76
78
|
|
2
訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,6 +16,10 @@
|
|
16
16
|
|
17
17
|
JS
|
18
18
|
|
19
|
+
<script>
|
20
|
+
|
21
|
+
window.onload=function(){
|
22
|
+
|
19
23
|
var a=[];
|
20
24
|
|
21
25
|
var formdata = new FormData();
|
@@ -26,15 +30,37 @@
|
|
26
30
|
|
27
31
|
formdata.append("a[]",a[i]);
|
28
32
|
|
33
|
+
}
|
34
|
+
|
35
|
+
let xmlhttp = new XMLHttpRequest();
|
36
|
+
|
37
|
+
xmlhttp.overrideMimeType("text/plain; charset=utf-8");
|
38
|
+
|
39
|
+
xmlhttp.addEventListener('loadend', function(){
|
40
|
+
|
29
|
-
|
41
|
+
if(xmlhttp.status === 200){
|
42
|
+
|
43
|
+
alert(xmlhttp.responseText);//abcが返ってくればok
|
30
44
|
|
31
45
|
}
|
32
46
|
|
47
|
+
});
|
33
48
|
|
49
|
+
|
50
|
+
|
51
|
+
xmlhttp.open("POST", ".", true);
|
52
|
+
|
53
|
+
xmlhttp.send(formdata);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
</script>
|
34
58
|
|
35
59
|
|
36
60
|
|
37
61
|
PHP
|
62
|
+
|
63
|
+
<?php
|
38
64
|
|
39
65
|
if(isset($_POST["a"])){
|
40
66
|
|
@@ -44,10 +70,12 @@
|
|
44
70
|
|
45
71
|
for($i=0;$i<$c;$i++){
|
46
72
|
|
47
|
-
echo $j[$i];
|
73
|
+
echo $j[$i];//abcを出力したい
|
48
74
|
|
49
75
|
}
|
50
76
|
|
51
77
|
}
|
52
78
|
|
79
|
+
?>
|
80
|
+
|
53
81
|
```
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,6 +26,8 @@
|
|
26
26
|
|
27
27
|
formdata.append("a[]",a[i]);
|
28
28
|
|
29
|
+
//XHRでサーバへ送信処理 割愛
|
30
|
+
|
29
31
|
}
|
30
32
|
|
31
33
|
|