Cross origin ajax request(jQuery)
Cross origin ajax request using jquery
JavaScript
$.ajax({
type: 'GET',
url: 'http://api.timezonedb.com/?zone=Asia/Kolkata&format=json&key=H0D2J8S4X880',
contentType: 'text/plain',
xhrFields: {
withCredentials: false
},
headers: {
// Set any custom headers here.
// If you set any non-simple headers, your server must include these
// headers in the 'Access-Control-Allow-Headers' response header.
},
success: function(data) {
if(data.status == 'OK'){
alert('Success')
}else {
alert(new Date());
}
},
error: function() {
alert(new Date())
}
});