HTTP Ajax Request via HTTPS Page
This is not possible due to the Same Origin Policy.
You will need to switch the Ajax requests to https, too.
AJAX Request From HTTPS Page to HTTP Url
According to W3, it's not possible through a COR policy due to "certificate errors"
http://www.w3.org/TR/access-control/#user-agent-security
Ajax GET request over HTTPS
You cannot make an AJAX request to an https
page if you are currently in http
because of the Same Origin Policy.
The host, port and scheme (protocol) must be the same in order for the AJAX request to work.
You can either make sure that the originating page is on the same host and scheme or implement CORS (cross-origin resource sharing) on the target domain to permit this particular request.
HTTPS request via AJAX from HTTP page
Yes this would be a Cross domain posting and would be blocked by the browser.
How can I make an Ajax call to an HTTP time server site from HTTPS?
You can't.
From HTTPS, only HTTPS. From HTTP you can call HTTP and HTTPS.
What you could do is to create an https wrapper (in php or node) in your own webserver and retrieve the value from timeapi.org from there.
Something like this:
<?php
header('Content-Type: application/json');
echo(file_get_contents('http://timeapi.org/utc/now.json'));
Mixed content blocked when running an HTTP AJAX operation in an HTTPS page
If you load a page in your browser using HTTPS, the browser will refuse to load any resources over HTTP. As you've tried, changing the API URL to have HTTPS instead of HTTP typically resolves this issue. However, your API must not allow for HTTPS connections. Because of this, you must either force HTTP on the main page or request that they allow HTTPS connections.
Note on this: The request will still work if you go to the API URL instead of attempting to load it with AJAX. This is because the browser is not loading a resource from within a secured page, instead it's loading an insecure page and it's accepting that. In order for it to be available through AJAX, though, the protocols should match.
Forcing AJAX call to be HTTPS from HTTPS Page
Try use another extension or use like folder with .htaccess etc. like this
var url = "https://etc/path/to/other/page/";
Related Topics
Are Braces Necessary in One-Line Statements in JavaScript
Scrolling an Iframe with JavaScript
Regular Expression for Password Validation
Create Svg Tag with JavaScript
Checking If Jquery Is Loaded Using JavaScript
How to Post Form Data with Fetch API
Map and Filter an Array at the Same Time
How to 'Minify' JavaScript Code
Download and Open PDF File Using Ajax
Object Method with Es6/Bluebird Promises
Make Several Requests to an API That Can Only Handle 20 Request a Minute
Benefits of Prototypal Inheritance Over Classical
How to Get Evaluated Attributes Inside a Custom Directive
How to Use Underscore.Js as a Template Engine
Which Keycode for Escape Key with Jquery
How to Programatically Select an HTML Option Using JavaScript