javascript - Using Typeahead with SignalR -


i attempting use typeahead signalr implementation. happening hub getting hit , returning value, result after .done() undifined. cannot work out why?

javascript

$(function () {      var search = $.connection.searchhub;     $.connection.hub.start().done(function () {          $('#searchbar').typeahead(null, {             minlength: 2,              // begin source                   source: function (query, process) {                 var suggestions = [];// callback value                   search.server.search(query)                         .done(function (result) {                             console.log(result);                             $.each(result, function () {                                 console.log(result);                                 suggestions.push(this);                                 process(suggestions);//process callback method                             });                         }).fail(function (error) {                             console.log(error);                             process([]);//process callback method, don't know if necessary here, produce no suggestions                         });             }         });      }); 

hub:

[hubname("searchhub")]     public class searchhub : hub     {         public async task search(string query)         {             api = new movieapi();             var result = await api.search(query);              if (result.results != null)             {                 clients.client(context.connectionid).results(result.results[0].title);             }             else             {                 clients.client(context.connectionid).noresults("there no search results!");             }          }     } 

your search method not return not strange undefined. need change task<t> , return something

also can not see subscribing results or noresults? like

search.client.results = function(result) {    console.log(result); }; 

edit: strange use signalr this, standard rest request/response should fine here


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -