JSON return with error: Syntaxerror: Missing ; before statement

Asked

Viewed 210 times

0

I have a problem with the JSON return, and I have already researched and I could not solve. I have the following requisition:

  var url = 'http://zcash.flypool.org/api/miner_new/t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63?callback=?';

  $.getJSON(url, function(data){
    alert(data);
  });

And makes the following mistake:

SyntaxError: missing ; before statement[Learn More]  t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63:1:10

Can someone help me solve this problem, or give me a light on how to solve?

Thank you!

  • The error occurs in these lines of code same?

  • In Firefox console, return in JSON. SyntaxError: missing ; before statement[Learn More] t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63:1:10

  • Try to get the ?callback=? end of url to see what happens...

  • Makes another mistake: Requisição cross-origin bloqueada: A política de mesma origem (Same Origin Policy) impede a leitura do recurso remoto em http://zcash.flypool.org/api/miner_new/t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63. (Motivo: o cabeçalho CORS 'Access-Control-Allow-Origin' não está presente).

  • 1

    This already answers. You are not allowed to get the data from another domain. Read this and this for more details.

  • Um, thank you. But there would be some way to recover the data from this link: http://zcash.flypool.org/api/miner_new/t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63 ?

  • I tried to read in python: HTTP Error 403: Forbidden, that is, blocked public access, although it is possible to read via Rowse (there just use the 'creativity') :-)

  • I don’t understand this 'creativity' kkkkk But there is no way: save to localStorage, and filter later?

  • 1

    Dude, I was able to get the data using the file_get_contents PHP, you can make an ajax for a local server and this server make the request and then return to javascript... is a way...

  • 1

    @Juniornunes thanks for the tip! I managed to solve so =)

  • @Guilhermelirio, creates a short answer of how you managed to solve and marks as a solution to help the next people who have the same question!! thanks!

Show 6 more comments

1 answer

1

The error is happening because you did not set a function to callback. I’ll give you an example of how you solve this.

function teste(r){console.log(r);}
var url = 'http://zcash.flypool.org/api/miner_new/t1UjazwJJnrUGoPh4GJYJ9FV6sYFzYg6H63?callback=teste';

 $.getJSON(url, function(data){
   alert(data);
 });
  • Buddy, it didn’t work here: Requisição cross-origin bloqueada: A política de mesma origem (Same Origin Policy) impede a leitura do recurso remoto em http://zcash.flypool.org/api/miner_new/t1UjazwJJnrUGoPh4GJYJ‌​9FV6sYFzYg6H63. (Motivo: o cabeçalho CORS 'Access-Control-Allow-Origin' não está presente).

  • 1

    Now it’s cross-origin problem, solved the error you mentioned, there are topics here in stackoverflow referring to this problem, you can do a search to understand better.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.