-
Notifications
You must be signed in to change notification settings - Fork 0
/
with-jsonp.html
23 lines (22 loc) · 888 Bytes
/
with-jsonp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSONP Example</title>
</head>
<body>
<div class="js-display"></div>
<script type="text/javascript">
function writeResponse(response) {
const displayEle = document.querySelector(".js-display");
displayEle.innerHTML = response.text;
}
/*
<script> tags are not bounded by CORS.
The `writeResponse` function is passed in our script src, and is executed with our server data.
*/
</script>
<script type="text/javascript" src="http://localhost:8000/api/text/jsonp?callback=writeResponse"></script>
<script type="text/javascript" src="http://localhost:8000/api/text/jsonp?callback=(function(a) { console.log(a); })"></script>
</body>
</html>