Yahoo JSONP Ajax Request Wrapped in callback function

前端 未结 5 1976
孤独总比滥情好
孤独总比滥情好 2020-12-06 21:38

I understand that I can make a crossdomain ajax call with jquery, .ajax, and jsonp. I am calling the yahoo stock quote api. Everything is working and the result is returning

5条回答
  •  执笔经年
    2020-12-06 22:14

    Here's an amended version that worked for me:

    $(document).ready(function() {
        $.ajax({
            url: "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22AAPL%22)%0A%09%09&format=json&diagnostics=true&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=quote",
            dataType: "jsonp"
        });
    
        window.quote = function(data) {
            console.log(data);
        };
    });
    

提交回复
热议问题