0

I am trying to read a json file with in javascript with the json url as https protocol. I am able to read the json file with http as url using HttpClientRequest, but get the below error while trying to access the https Url using the same javascript code. Can you please help me understand the same.

Below the javascript code

var jsonURL = 'https://***********.json'
logInfo('URL:' + jsonURL);
var http = new HttpClientRequest(jsonURL); 
http.execute();
logInfo('Body' +http.response.body.toString());
logInfo('Parsing ...');
obj = JSON.parse(http.response.body.toString());
logInfo('Parsed : ' + obj[0].day);

I encounter this error

Error in SSL library: 'error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (code 336032784)'

Adithya
  • 1
  • 1
  • Do you really need to use a `HttpClientRequest`? You should try it with `XMLHttpRequest`. – ForceMagic Jul 14 '16 at 12:14
  • You're trying an ajax request over https Look here: http://stackoverflow.com/questions/15375908/ajax-get-request-over-https – francesco.s Jul 14 '16 at 12:20
  • What is HttpClientRequest exactly in JavaScript? – epascarello Jul 14 '16 at 12:22
  • Thank you All for your quick replies. I need to implement the code inside a tool and will be used inside java script code, Can you help me with the code snippet for using in the javascript. – Adithya Jul 14 '16 at 13:04

2 Answers2

0

You should try this way of rendering your JSON using google API

function setJson(content) {
    document.getElementById('output').innerHTML = content;
}

// create script element
var jsonScript = document.createElement('jsonScriptscript');
// assing src with callback name
jsonScript.src = 'https://www.googleapis.com/freebase/v1/text/en/bob_dylan?callback=insertReply';
// insert script to document and load content
document.body.appendChild('jsonScriptscript');
0

First of all, be sure that remote host has meta value Access-Control-Allow-Origin: *. If it won't work, try to use XMLHttpRequest.