I try to get server progress with own API. When I just do simple API request, all browser(win & mac) work fine. But while started heavy server process and waiting the reponse, the simple API request not work using only Safari (MacOS & iOS). The other browser(win and mac) work fine.
[console error (only 1 line)]
XMLHttpRequest cannot load https://mydomain/api/WebJsOcrTest/ due to access control checks.
I researched the issue by the error log on the web. And I have guessed the reason is caused by CORS at first and tried to set the 'Access-Control-Allow-Origin' on my server response and etc, but not work. In addition, without waiting server response, the request work fine all. So I think the CORS may not be the cause.
Do I set any bad in my code?
I appreciate any help and hint for this problem.
Environment:
WinServer2016 IIS
ASP.net WebForms
jquery-3.6.0(tried 2.2.4 but same)
macOS Big Sur 11.0.1 Safari 14.0.1
iOS 15.5 Safari 604.1
tested browser:
Win Chrome, Edge, FF
Mac Chrome, Safari, FF
Client Code:
<form id="form1" runat="server">
<div>
<input id="btnSimpleAjax" type="button" value="BtnSimpleAjax"/>
</div>
<div>
<asp:Button ID="ServerHeavyWork" runat="server" Text="ServerHeavyWork" OnClick="ServerHeavyWork_Click"/>
</div>
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script>
$('#btnSimpleAjax').on('click', function () {
$.ajax({
url: '/api/WebJsOcrTest/',
type: 'POST',
dataType: "json",
timeout: 5000
}).done((data) => {
alert(data)
}).fail(function (jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
console.log(textStatus);
console.log(errorThrown);
});
});
</script>