Suppose I have a server at this URL: https://example.com/employee, and its returns JSON data. I want to retrieve this data using Jquery on iPhone. I wrote this code :
$.ajax {
type: "POST",
contentType: "application/json; charset=utf-8",
url: "https://example.com/employee",
data: "{}",
dataType: "json"
success: function(res) {
}
});
Is this the right way to make this HTTPS request, or I need to do some other authentication also? Currently it does not work on iPhone.
It returns JSON data in Firefox, Chrome, IE, Safari, but it doesn’t return anything on iPhone.
What are you trying to do is JSON, not JSONP. This restriction is called Same Origin Policy
Try this
and in that server-side script use something like
and it should work 😉