1

I'm having trouble with the API for Last.FM.

The following code is on my localhost and works. I get the expected result.

var url="http://ws.audioscrobbler.com/2.0/?method=geo.gettopartists&country=spain&api_key=xxxxxxxxxxx&format=json&callback=?";
                $(document).ready(function()
                 {
                    $.getJSON(url, function(data)
                    {

                    });
                 });

However when I set up a small webservice, say "www.example.com/hello", the following script on my localhost does not work. (It should return "hello".)

var url="www.example.com/hello";
                    $(document).ready(function()
                     {
                        $.get(url, function(data)
                        {

                        });
                     });

Now, I get a cross origin policy problem.

Farray
  • 8,290
  • 3
  • 33
  • 37
Noor
  • 19,638
  • 38
  • 136
  • 254

1 Answers1

1

for more information see this How to use Cross domain Ajax request and my answer for this question $.ajax call working fine in IE8 and Doesn't work in firefox and chrome browsers

Community
  • 1
  • 1
Chamika Sandamal
  • 23,565
  • 5
  • 63
  • 86
  • But how is it that the first peice of code works wells and while that as soon that i changes the url, it doesn't, do i have to make any modifications on the server side – Noor Feb 18 '12 at 16:44
  • first one is JSONP enabled service and second one is not. if you follow the tutorial you will understand how to enable it. – Chamika Sandamal Feb 18 '12 at 16:46
  • lol, don't worry, if the answer is correct, i'll surely tick it :) – Noor Feb 19 '12 at 11:49