1
내가 JS 렌더링 대렌더링 JSON
을 예상대로이 확실히 작동하지 않는 이유를 알아 내기 위해 JSON .Trying 렌더링 만약 내가 다른 결과를 얻고 내 자바 스크립트는 다음과 같습니다:
$(function() {
$('.delete_post').bind('ajax:success', function() {
$(this).closest('tr').fadeOut();
}
)
});
컨트롤러 :
작품
respond_to do |format|
format.js { render :nothing => true}
end
개 작품
respond_to do |format|
format.js { head :ok }
end
작품
respond_to do |format|
format.json { render :json => {} }
end
는가
respond_to do |format|
format.json { head :ok }
end
작동하지 않습니다 작동하지 않습니다
,respond_to do |format|
format.json { render :nothing => true }
end
아약스 응답에서 무슨 일이 일어나는지 조사 할 때 작동하지 않는 경우 "parseError"가 표시됩니다.
나는 Content-type이 다시 보내지는 것을 이해하지만 (텍스트/자바 스크립트 대 applicaiton/json), 서버로 200을 되돌려 보내고 있기 때문에 마지막 두 가지 경우는 여전히 작동 할 것으로 예상됩니다.
(코드에서 유래 : http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/)
도움이 될 것입니다. http://stackoverflow.com/questions/5213956/what-means-location-and-head-ok-in-the-responto-format-statemen – PhillipKregg
해당 링크가 유용합니다. 200 응답을 보내는 이유/방법을 설명합니다. "Does not work"케이스에서 200 개의 응답을 보내고 있지만 여전히 javascript 내에서 "parseError"에 들어가는 것을 알고 있습니다. – Hortitude