I'm having a problem with my ajax displaying the response in an alert.
I use jquery and ajax. The javascript contains a normal GET-Request. The ajax doesn't go to the .done function. The website displays the second alert:
alert("Sorry. Server unavailable. ");
But in the browser it displays in the console. I'm using firefox + a Plug-in for Firefox (https://addons.mozilla.org/de/firefox/addon/cors-everywhere/reviews/). I don't think the plugin is the proplem because without the plugin it's also working.
So here is my html:
<html>
<head>
<meta charset="utf-8" />
<title>Peyer E1 9.2 Auswahl</title>
<script src="clearcache.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<button onclick="data()">Test</button>
</body>
</html>
Here is my Javascript:
function data() {
$.ajax({
type: "GET",
url: "url",
dataType: "application/json",
headers: {
"Authorization": "Basic",
"Cache-Control": "no-cache"
}
}).done(function() {
alert("Success.");
}).fail(function() {
alert("Sorry. Server unavailable. ");
});
}