Doubt consume json with AJAX

Asked

Viewed 33 times

1

I created this code at the test level to try to consume a "json" via AJAX. I’d like you to tell me where I’m going wrong I’m getting this mistake:

json.html:1 Xmlhttprequest cannot load http://vagalumewifi.com.br/timeline. Response to preflight request doesn’t pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested Resource. Origin 'http://127.0.0.1:49844' is therefore not allowed access.

Follow my code below, thanks in advance!

var jsonTeste = function(){
    $(".botao-teste").click(function(e){
        e.preventDefault();
        $.ajax({
            url: "vagalumewifi.com.br/timeline.json",
            headers: {'X-Requested-With': 'XMLHttpRequest'},
            dateType: "json",
            success: function(retorno){
              $.each(retorno.timeline, function(){
                  var conteudo = this;
                  alert(conteudo.content);
              })  
            }
        })
    })
};
$(jsonTeste);
  • The problem is that Voce is making the ajax request for another domain, Voce has access to the http://vagalumewifi.com.br/timeline?

  • tried to put the type as get?

  • The link is public friend

  • I already put "get","json",jsonp and nothing

  • Hi Anderson! I marked the answer as a duplicate of another. Refer to the problem you are having, basically the other domain does not allow external connections. You have to use a proxy (server) or iframe.

  • Thanks friend!

Show 1 more comment
No answers

Browser other questions tagged

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