Noor
Noor

Reputation: 20150

Cross origin policy error with jQuery get

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.

Upvotes: 1

Views: 154

Answers (1)

Chamika Sandamal
Chamika Sandamal

Reputation: 24312

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

Upvotes: 1

Related Questions