Im using thinking sphinx and it has become necessary to pull out the search results as JSON array with callback (JSONP). In my other functions like show, adding .json?callback=asd to the url allows this. But not for what i have retrieved with thinking_sphinx. This is what my index looks like
def index
@profiles = Profile.search params[:search], :match_mode => :any
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @profiles, :callback => params[:callback] }
end
end
Ive been able to say /profiles.json?search=what to get a json. But how do i get a callback
What kind of url do i need to send, or other change i need to make, to get the right format for my models — wrapperFunction(arrayOfJSONs)
Just add the callback as another query parameter:
Just substitute
<query>and<callbackname>with your values.