股票代码预售错误

时间:2015-03-20 11:50:44

标签: javascript jquery jsonp yahoo-finance

当用户开始在输入框中输入字符时,我试图使这种预先输入功能正常工作。

<input id="visualtxtSymbolLookup" type="text" placeholder="type to search stocks" />

脚本看起来像这样;

<script>
 $( "#visualtxtSymbolLookup" ).autocomplete({
  source: function( request, response ) {
    $.ajax({
        type: "GET",
        dataType: "jsonp",
        jsonp: "callback",
        jsonpCallback: "YAHOO.Finance.SymbolSuggest.ssCallback",
        data: {
            query: request.term
        },
        cache: true,
        url: "http://d.yimg.com/autoc.finance.yahoo.com/autoc"
    }); // .ajax
    var YAHOO = window.YAHOO = {Finance: {SymbolSuggest: {}}};
    YAHOO.Finance.SymbolSuggest.ssCallback = function (data) {
      var mapped = $.map(data.ResultSet.Result, function (e, i) {
            return {
                label: e.symbol + ' (' + e.name + ')',
                value: e.symbol
            };
        });
        response(mapped);
    }; // YAHOO.Finance     
  },
    minLength: 2 //source: function
  });

我得到的唯一错误是:

未捕获的TypeError:undefined不是函数(匿名函数)

0 个答案:

没有答案