FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
APIJSON/APIJSON-JavaScript/APIJSON-JS/get/array.html at master · billjazz/APIJSON · GitHub
billjazz
/
APIJSON
Public
forked from
APIJSON/APIJSON
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
APIJSON
/
APIJSON-JavaScript
/
APIJSON-JS
/
get
/
array.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (42 loc) · 1.31 KB
Breadcrumbs
APIJSON
/
APIJSON-JavaScript
/
APIJSON-JS
/
get
/
array.html
Copy path
File metadata and controls
52 lines (42 loc) · 1.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html
>
<
html
>
<
head
>
<
meta
charset
="
UTF-8
"
>
<
title
>
GET:Array
</
title
>
<
script
type
="
text/javascript
"
src
="
../RequestUtil.js
"
>
</
script
>
</
head
>
<
body
>
<
script
>
//单对象数组请求的简单方式
var
rq
=
getArray
(
"User"
,
{
"name$"
:
"%o%"
}
,
5
,
1
,
false
,
callBack
)
;
//普通方式<<<<<<<<<<<<<<<<<<<<<<<<<<
// var json = {
// "User[]":{
// "count":5,
// "page":1,
// "User":{
// "name$":"%o%" //已通过encode函数自动转义 encodeURIComponent("%o%")
// }
// }
// };
//
// var rq = request(URL_GET, json, false, callBack);
/**回调函数
*/
function
callBack
(
)
{
var
rp
=
JSON
.
parse
(
rq
.
responseText
)
;
alert
(
"Response:\n"
+
format
(
JSON
.
stringify
(
rp
)
)
)
;
var
arr
=
rp
==
null
?
null
:
rp
[
"User[]"
]
;
//取出数组User[]
if
(
arr
!=
null
)
{
alert
(
"User[].length = "
+
arr
.
length
)
;
var
user0
=
arr
==
null
||
arr
.
length
<=
0
?
null
:
arr
[
0
]
;
//取出User[]第0项
if
(
user0
!=
null
)
{
alert
(
"User[]/0 = \n"
+
format
(
JSON
.
stringify
(
user0
)
)
)
;
alert
(
"User[]/0/id = "
+
user0
.
id
)
;
//取出并显示User[]第0项User的id
alert
(
"User[]/0/name = "
+
user0
.
name
)
;
//取出并显示User[]第0项User的name
}
}
}
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL