0

How can I get JSON from http get request in javascript? The URL is:

    http://www.streamfinder.com/api/?api_codekey=[devkey]&do=get_genre_list&return_data_format=json

I have already tried a lot of stuff, but none of them seem to work... I have tried this, but it is also not working.

function httpGet(theUrl)
{
    var xmlHttp = null;

    xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false );
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
user1176999
  • 440
  • 8
  • 20

1 Answers1

1

The problem was that i was using json instead of jsonp. The code that worked is this:

$.ajax({
        url: "URL",
        type: 'GET',
        dataType: 'jsonp',
        success: function(res) {

            alert(JSON.stringify(res));
        }

    });
user1176999
  • 440
  • 8
  • 20