0

I am trying to use JQuery ajax call from fiddle to load a resource from this page

My code is here:

$('button').on('click', function() {
    $('#message').text('');
    $.ajax({
        url: "http://pool.burstcoin.ro/pending2.json",
        type: "GET",
        crossDomain: true,
        dataType: "json",
        success: function(response) {
            console.log(response);
            $('#message').text(response.message);
        },
        error: function(xhr, status) {
            alert("error");
        }
    });
});

I have created the fiddle just to see if I can get to any sort of response but I am getting this js error response: No 'Access-Control-Allow-Origin' header is present on the requested resource. I have read some post on this and if I am not mistaken it's not possible to do anything on the front end to add the missing headers. Is it possible to add the right headers in Node.js (or some other javascript framework) to the response? If so, I would really appreciate an updated fiddle that demonstrates that because of my lack of knowledge to do it myself.

Dracke
  • 651
  • 2
  • 11
  • 30
  • The server that is serving http://pool.burstcoin.ro/pending2.json needs to add the Access-Control-Allow-Origin response header. – Khlbrg Mar 13 '18 at 18:16
  • Just change your dataType to "jsonp" : http://jsfiddle.net/o5yq4ajn/4/ – DinoMyte Mar 13 '18 at 18:19

1 Answers1

0

Solved using Yahoo's YQL

Fiddle

function GetMessages()
{

$.getJSON("http://query.yahooapis.com/v1/public/yql",
  {
    q:      "select * from json where url=\"http://pool.burstcoin.ro/pending2.json\"",
    format: "json"
  },
  function (data) {
    if (data.query.results) {
        alert(data.query.results["pendingPaymentList"]["_00079785104091711"]);
    } else {
      alert('bad');
    }
  }
);
}

GetMessages();
Dracke
  • 651
  • 2
  • 11
  • 30