質問編集履歴

1

問題を再現できる最小コードを作成しました。

2017/08/16 03:48

投稿

Qoo
Qoo

スコア1249

test CHANGED
File without changes
test CHANGED
@@ -6,69 +6,135 @@
6
6
 
7
7
 
8
8
 
9
- ```javascript
9
+ test.html
10
10
 
11
- var textData = [];
11
+ ```
12
12
 
13
- $('#screen .text').each(function () {
13
+ <!DOCTYPE html>
14
14
 
15
- i++;
15
+ <html>
16
16
 
17
-
17
+ <head>
18
18
 
19
- textData.push({
19
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
20
20
 
21
- text: $(this).text(),
21
+ <title></title>
22
22
 
23
- x: $(this).position().left ,
23
+ <meta charset="utf-8" />
24
24
 
25
- y: $(this).position().top ,
25
+ </head>
26
26
 
27
- width: $(this).outerWidth() ,
27
+ <body>
28
28
 
29
- height: $(this).outerHeight() ,
29
+ <script src="js/jquery-1.10.1.min.js"></script>
30
30
 
31
- fontName: $(this).data('fontFamily'),
32
-
33
- fontSize: $(this).data('fontSize'),
34
-
35
- color: $(this).data('color')
31
+ <script>
36
-
37
- });
38
-
39
- });
40
32
 
41
33
 
42
34
 
43
- data.append('textData', textData);
35
+ var data = new FormData();
44
36
 
37
+ var textData = [];
38
+
39
+
40
+
41
+ textData.push({
42
+
43
+ text: "aaa",
44
+
45
+ });
46
+
47
+
48
+
45
- data.append('textDataCount', i.toString());
49
+ data.append('textData', textData);
46
50
 
47
51
 
48
52
 
49
- var options = {};
53
+ var options = {};
50
54
 
51
- options.url = "FileUp.ashx";
55
+ options.url = "test.ashx";
52
56
 
53
- options.type = "POST";
57
+ options.type = "POST";
54
58
 
55
- options.data = data;
59
+ options.data = data;
56
60
 
57
- options.contentType = false;
61
+ options.contentType = false;
58
62
 
59
- options.processData = false;
63
+ options.processData = false;
60
64
 
61
- options.success = function (r) {
65
+ options.success = function (r) {
62
66
 
63
-
64
67
 
65
- if (r == "OK") {
66
68
 
67
- }
69
+ };
68
70
 
69
-
71
+
70
72
 
73
+ $.ajax(options);
74
+
75
+
76
+
77
+
78
+
79
+ </script>
80
+
81
+
82
+
83
+ </body>
84
+
85
+ </html>
86
+
87
+ ```
88
+
89
+
90
+
91
+ ```test.ashx
92
+
93
+ <%@ WebHandler Language="C#" Class="test" %>
94
+
95
+
96
+
97
+ using System;
98
+
99
+ using System.Web;
100
+
101
+
102
+
103
+ public class test : IHttpHandler
104
+
105
+ {
106
+
107
+
108
+
109
+ public void ProcessRequest(HttpContext context)
110
+
111
+ {
112
+
113
+ Console.WriteLine(context.Request.Form["textData"].ToString());
114
+
115
+ Console.WriteLine(context.Request.Form["textData"[0]].ToString());
116
+
71
- };
117
+ }
118
+
119
+
120
+
121
+ public bool IsReusable
122
+
123
+ {
124
+
125
+ get
126
+
127
+ {
128
+
129
+ return false;
130
+
131
+ }
132
+
133
+ }
134
+
135
+
136
+
137
+ }
72
138
 
73
139
 
74
140
 
@@ -76,26 +142,8 @@
76
142
 
77
143
 
78
144
 
145
+ (context.Request.Form["textData"].ToString()をウォッチで確認すると、
79
146
 
147
+ "[object Object]"となっていました。
80
148
 
81
- ```c#
82
-
83
- context.Request.Form["textData"]
84
-
85
- ```
86
-
87
-
88
-
89
- 上記をウォッチで確認すると、"[object Object],[object Object],[object Object]"となっており、
90
-
91
- この中身を取得したいのですが、
92
-
93
- context.Request.Form["textData"[0][text]];
94
-
95
-
96
-
97
- でも配列の中身を取得することができません(nullになっている)
98
-
99
- 実際の値はnullではないことは確認済です。
100
-
101
- 配列の中身を取得するにはどのようにすればよいでしょか。
149
+ 配列のtextData.textの値を取得したいのでが、どのようにすればよいでしょか。