Search code examples
jqueryajaxhttphttpsmixed-content

I want to communicate with api http from https


I have the following code

  $.getJSON('http://www.mindicador.cl/api', function(data) {
            var dailyIndicators = data;
            $("<p>", {
                html: 'UF : $' + dailyIndicators.uf.valor +
                      '     DOLAR : $' + dailyIndicators.dolar.valor +
                      '     EURO : $' + dailyIndicators.euro.valor 
            }).appendTo(".valor");
            $("#load_valor").hide();
        }).fail(function() {
            console.log('Error al consumir la API!');
        });

My website is https and the api website is http.

throws the following error in console navigator:

español: Se ha bloqueado la carga del contenido activo mixto "http://www.mindicador.cl/api"[Saber más]

in english should be so: blocked loading mixed active content "http://www.mindicador.cl/api"

How I can communicate with the API?

is possible?


Solution

  • Use Postman to debug AJAX calls to your API.

    Using protocol-agnostic requests should fix the issue:

    $.getJSON('//www.mindicador.cl/api', function(data) { ... });
    

    Here is a complete description of your errror Why am I suddenly getting a "Blocked loading mixed active content" issue in Firefox?