I'm trying to make jQuery Autocomplete, Yahoo Finance and Zend Framework work together.
What I want is to create a form field in which I can autocomplete tickers symbols through Yahoo API.
I've already created a Zend_From element that contains this :
$this->setJQueryParam('source', new Zend_Json_Expr('function( request, response ) {
$.ajax({
type: "GET",
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "YAHOO.Finance.SymbolSuggest.ssCallback",
data: {
query: request.term
},
cache: true,
url: "http://autoc.finance.yahoo.com/autoc";
}
});
}'));
$this->getView()->jQuery()->addJavascript('var YAHOO={Finance:{SymbolSuggest:{}}};');
$this->getView()->jQuery()->addOnLoad('YAHOO.Finance.SymbolSuggest.ssCallback = function (data) {
console.log(JSON.stringify(data)); }');
I found this post that resolved a part of my problem, but I think using var YAHOO={Finance:{SymbolSuggest:{}}};
is a dirty trick and isn't the right way to do.
Now, if I type GOO in my field, then the firebug console will show me something like this:
{"ResultSet":{"Query":"goo","Result":[{"symbol":"GOOG","name":"Google Inc.","exch":"NMS","type":"S","exchDisp":"NASDAQ","typeDisp":"Equity"},{"symbol":"GT","name":"Goodyear Tire & Rubber Co.","exch":"NYQ","type":"S","exchDisp":"NYSE","typeDisp":"Equity"}...
which is great, but I don't know how to send back these data to Autocomplete from this callback function, any idea?