1

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?

Anand Bhat
  • 5,591
  • 26
  • 30
MagX8
  • 13
  • 2

2 Answers2

1

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?

Community
  • 1
  • 1
halfzebra
  • 6,771
  • 4
  • 32
  • 47
  • 1
    Thanks for comment. I have solved obtaining the json from php and then called from jquery. Not sure if it the optimal solution, but the data I get are public data. question: this would be a web service? $ data = file_get_contents ("http://www.mindicador.cl/api"); echo $ data; What security do you recommend for that file .php? – MagX8 Jul 19 '15 at 16:42
  • 1
    @MagX8 [Here](http://stackoverflow.com/a/17990092/2294657) is one of the best advices regarding handling AJAX calls in PHP. – halfzebra Jul 19 '15 at 16:47
0

Tricky, first thing I can think of is to make something server side on your own web server with the https certificate that essentially makes the request for you, you can then get the javascript to pull the data from that instead. Bit of overhead but I really don't see how you can get round it otherwise...

nckblu
  • 11
  • Thanks for comment. I have solved obtaining the json from php and then called from jquery. Not sure if it the optimal solution, but the data I get are public data. question: this would be a web service? $ data = file_get_contents ("http://www.mindicador.cl/api"); echo $ data; What security do you recommend for that file .php? – MagX8 Jul 19 '15 at 16:40