2011-12-01 4 views
0

메신저 스핑크스를 생각하면 검색 결과를 콜백 (JSONP)이있는 JSON 배열로 가져와야합니다. show와 같은 다른 함수에서 url에 .json? callback = asd를 추가하면이를 허용합니다. 하지만 thinking_sphinx로 검색 한 내용이 아닙니다. 내 색인은 다음과 같습니다.레일스 JSON 콜백 - 스핑크스

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 

jpro을 얻으려면 /profiles.json?search=what라고 말할 수있었습니다. 그러나 콜백을 얻는 방법 내 모델의 올바른 형식을 얻으려면 어떤 종류의 URL을 보내거나 다른 변경이 필요합니까? wrapperFunction (arrayOfJSONs)

답변

3

콜백을 다른 것으로 추가하기 만하면됩니다. 쿼리 매개 변수 :

/profiles.json?search=<query>&callback=<callbackname> 

은 그냥 값 <query><callbackname>를 대체합니다.

+0

감사합니다 !!!. 이 작품. – jack

관련 문제