Repository navigation
Expand file tree
/
Copy pathAPI5.html
More file actions
70 lines (61 loc) · 2.05 KB
/
Copy pathAPI5.html
File metadata and controls
70 lines (61 loc) · 2.05 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>
</head>
<body>
<input id="getdata" type="button" value="Send X GET"/>
<input id="postdata" type="button" value="Send X POST" />
<script>
$(document).ready(function()
{
var contentType ="application/x-www-form-urlencoded; charset=utf-8";
if(window.XDomainRequest)
contentType = "text/plain";
$("#postdata").click(function()
{
$.ajax({
url:"http://iwashthecarspa.com/api/washtype.php",
// url:"https://yts.am/api/v2/list_movies.json",
data:"",
type:"POST",
dataType:"json",
//crossDomain:"true",
cache:"false",
// Correct types for JS files : "application/javascript" ,"application/x-javascript",
contentType:"application/json",
success:function(data)
{
alert("Data from Server"+JSON.stringify(data));
},
error:function(jqXHR,textStatus,errorThrown)
{
alert("You can not send Cross Domain AJAX requests: "+errorThrown);
}
});
});
$("#getdata").click(function()
{
$.ajax(
{
url:"http://iwashthecarspa.com/api/washtype.php",
//url:"http://hayageektest.appspot.com/cross-domain-cors/get.php?name=Ravi&age=32",
dataType:"json",
contentType:"application/json",
crossDomain:"true",
success:function(data)
{
alert("Data from Server"+JSON.stringify(data));
},
error:function(jqXHR,textStatus,errorThrown)
{
alert("You can not send Cross Domain AJAX requests : "+errorThrown);
}
});
});
});
</script>
</body>
</html>