1

I'm using Freebase suggest. If user cannot find what he is looking for, he types it in the textfield and a new term is added into my database. The thing is, I would like suggest to search also through these added terms.

I found this answer, but I am not sure if it suits my needs, because I still want to see Freebase results. Any ideas?

Fergie
  • 1,913
  • 1
  • 12
  • 10

1 Answers1

1

Ok, after a few more hours of googling and thinking I have figured this out.

I add synchornous ajax call ('async':false) to beforeSend callback function in the suggest request function. It invokes a function which returns json array of values from my database. After asynchonous call to Freebase suggest service I add the two results together and display them.

That's it!

Fergie
  • 1,913
  • 1
  • 12
  • 10
  • That may be OK if your local database is very lightweight/fast, but it'd be better to fire off both requests asynchronously and merge the results when they're both complete so that you only have to wait max(t1,t2) rather than t1+t2. Something like what is done here: http://stackoverflow.com/questions/6538470/jquery-deferred-waiting-for-multiple-ajax-requests-to-finish – Tom Morris Jul 27 '12 at 17:08
  • Thank you. Btw you couldn't mark your answer as accepted in first two days otherwise I would do it immediately. – Fergie Jul 28 '12 at 21:44