1

I've created an simple AJAX call tho get JSON data from an cross domain URL. With the real URL i run allways in an error, an example with another cross domain call is running successful.

var json_url_1 =  'http://operation-wigwam.ingress.com:8080/v1/test-info?callback=parseResponse',
    json_url_2 =  'http://operation-wigwam.ingress.com:8080/v1/test-info',
    json_url_3 =  'https://jsonplaceholder.typicode.com/users/1';

$('#real1').click(function(){
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        url: json_url_1,
        xhrFields: {
            withCredentials: false
        },
        success: function( data ){
            console.log( data);
       },
       error: function() {
           console.log( 'an error occurred');
       }
    });
});

$('#real2').click(function(){
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        url: json_url_2,
        xhrFields: {
            withCredentials: false
        },
        success: function( data ){
            console.log( data);
        },
        error: function() {
            console.log( 'an error occurred');
        }
    });
});

$('#example').click( function(){
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        url: json_url_3,
        xhrFields: {
            withCredentials: false
        },
        success: function( data ){
            console.log( data );
        },
        error: function() {
            console.log( 'an error occurred');
        }
    });
});

What's going wrong with the original URL?

Example here: http://jsbin.com/cesehiy/edit?js,console,output

svebal
  • 57
  • 2
  • 8
  • If you own the ressource, look for [Access-Control-Allow-Origin](https://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work/10636765#10636765) – Louys Patrice Bessette May 27 '18 at 13:25
  • Possible duplicate of [How does Access-Control-Allow-Origin header work?](https://stackoverflow.com/questions/10636611/how-does-access-control-allow-origin-header-work) – Louys Patrice Bessette May 27 '18 at 17:05

0 Answers0