문제

Trying to write a simple call to google's JSON stock ticker API. I would like to get JSON, however, the same origin policy comes up. Any ideas of how to work around this? I've heard of using an iFrame, but was hoping for something simpler or more elegant.

Here is my call:

$('#ticker').change(function() {
      url = "http://www.google.com/finance/info?client=ig&q=" + this.value;
      $.getJSON(url, function(data) {
          alert(data);
        });
});

Any help is much appreciated!

도움이 되었습니까?

해결책

Put the data in your page before you serve it up. Make a server-to-server XMLHTTP call. Alternately there is JSONP:

http://api.jquery.com/jQuery.getJSON/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top