-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.html
40 lines (38 loc) · 1.32 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>CORS Tester</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
</head>
<body>
<H2>To view test result</H2>
<h3>Right click this page > Inspect Element > Console </h3>
<p id="out"></p>
<script>
console.log("starting ajax request to the resource.");
$.ajax
({type: "GET", //edit method
contentType: "json", //edit datatype: json, html, etc.dataType: "json",
url: "https://www.google.com", //edit host and port, example: http://198.0.1.20:8443/pat
headers: { //add any headers here
"X-AMEX-API-KEY":"test",
"Authorization":"test",},
xhrFields: { //optional
withCredentials: true
},
success: function(data)
{
console.log("API is CORS enabled, here's the result");
console.log(data);
$('#out').text(JSON.stringify(data));
},
done: function( jqXHR, textStatus ) {
console.log( "Request failed: " + textStatus + jqXHR );
},
});
console.log("ajax request sent.");
</script>
</body>
</html>