Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F946166
scriptJsonp.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
scriptJsonp.js
View Options
function
getJsonpCallback
(
url
){
var
result
=
null
;
var
idMatch
=
url
.
match
(
/jsonp=(.*?)(&|$)/
);
if
(
idMatch
){
result
=
idMatch
[
1
];
}
else
{
//jsonp didn't match, so maybe it is the jsonCallback thing.
idMatch
=
url
.
match
(
/callback=(.*?)(&|$)/
);
if
(
idMatch
){
result
=
idMatch
[
1
];
}
}
if
(
result
){
result
=
decodeURIComponent
(
result
);
}
return
result
;
}
function
findJsonpDone
(){
var
result
=
false
;
var
scriptUrls
=
getScriptUrls
();
for
(
var
i
=
0
;
i
<
scriptUrls
.
length
;
i
++
){
var
jsonp
=
getJsonpCallback
(
scriptUrls
[
i
]);
if
(
jsonp
){
eval
(
jsonp
+
"({animalType: 'mammal'});"
);
result
=
true
;
break
;
}
}
return
result
;
}
function
getScriptUrls
(){
//Get the script tags in the page to figure what state we are in.
var
scripts
=
document
.
getElementsByTagName
(
'script'
);
var
scriptUrls
=
new
Array
();
for
(
var
i
=
0
;
scripts
&&
i
<
scripts
.
length
;
i
++
){
var
scriptTag
=
scripts
[
i
];
if
(
scriptTag
.
id
.
indexOf
(
"dojoIoScript"
)
==
0
){
scriptUrls
.
push
(
scriptTag
.
src
);
}
}
return
scriptUrls
;
}
function
doJsonpCallback
(){
if
(
!
findJsonpDone
()){
alert
(
'ERROR: Could not jsonp callback!'
);
}
}
//Set a timeout to do the callback check, since MSIE won't see the SCRIPT tag until
//we complete processing of this page.
setTimeout
(
'doJsonpCallback()'
,
300
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 26, 05:29 (3 d, 11 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25759
Default Alt Text
scriptJsonp.js (1 KB)
Attached To
rZEDHG ZedLegacy
Event Timeline
Log In to Comment