Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have a $.ajax function where i have a direct api call to database to retrieve data. While i have tested all functions are working well and data returned are correct, these are not working after i have deployed them onto server and browse my web app using iOS Safari.
The static interface is loaded but not the data. Below are my sample codes:
JavaScript
var baseUrl = 'https://anythingAPI/;'

$.ajax({
       type: 'GET',
       url: baseUrl+ 'api/Customer/GetCustomerDetails',
       data: {},
       success: function (result) {
            console.log('Result Returned.')
       }
});


At first i thought is that i did not pass credential for authentication but Android Chrome is working well. Only Safari is unable to generate data.

What I have tried:

1. Removed the direct API call and replace with normal url. For example,
/Customer/GetCustomerDetails
in url and Safari works fine.
2. Tested on Android Chrome and Windows browsers(laptop) and all are working fine.
Posted
Updated 22-Jul-19 5:33am

1 solution

You need to enable CORS and make changes in web.config
XML
<pre><httpProtocol>
<customHeaders>
<!-- Allow Web API to be called from a different domain. -->
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Methods" value="*" />
</customHeaders>
</httpProtocol>
 
Share this answer
 
v2
Comments
Richard Deeming 22-Jul-19 15:10pm    
It's "CORS", not "cores". :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900