开发者

getJSON and invalid label

I am trying to get json data from a url. Url is working ok in FF. I am trying code like this

$.getJSON("http://testsite.com/1234/?callback=?", function(data){   
        //here i am getting invalid label error**
    }
);

When i am trying without callback开发者_StackOverflow=? i am getting empty data

$.getJSON("http://testsite.com/1234/", function(data){   
            //here i am data = ""
        }
    );

Whats going wrong?


It looks like the site you're fetching from doesn't support JSONP, with this URL:

http://testsite.com/1234/?callback=?

It's trying to use JSONP, but the server is returning a plain JSON response (not wrapped in a function).

With this URL:

http://testsite.com/1234/

It's not trying JSONP at all, and being blocked by the same-origin policy.


To fetch data from a remote domain, it needs to support JSONP so it can be grabbed with a GET request, so you'll need to either add support to that domain, or proxy the request through your own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜