-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.tmplate.js
47 lines (42 loc) · 1.04 KB
/
1.tmplate.js
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
function ex1() {
let lambdaURL = "{{ lambda_url }}";
// 1. 同じオリジンから読む
$.ajax({
contentType : "application/json",
dataType : "json",
type : "GET",
url : "js/dummy.js",
success : function(data) {
$("#msg1").text(data.time);
},
error : function(data) {
console.log("error", data);
}
})
// 2. 違うオリジンから読む
$.ajax({
// contentType : "application/json", // これがあるとpreflightが起きる
dataType : "json",
type : "GET",
url : lambdaURL,
success : function(data) {
$("#msg2").text(data.time);
},
error : function(data) {
console.log("error", data);
}
})
// 3. 違うオリジンから読む(preflightつき)
$.ajax({
contentType : "application/json", // これがあるとpreflightが起きる
dataType : "json",
type : "GET",
url : lambdaURL,
success : function(data) {
$("#msg3").text(data.time);
},
error : function(data) {
console.log("error", data);
}
})
}