3.0.0.beta3で新しいアプリを作成しています。次のアクション(publications_controller.rb内)のAjaxリクエストにjs.erbテンプレートをレンダリングしようとしています。
def get_pubmed_data
entry = Bio::PubMed.query(params[:pmid])# searches PubMed and get entry
@publication = Bio::MEDLINE.new(entry) # creates Bio::MEDLINE object from entry text
flash[:warning] = "No publication found."if @publication.title.blank? and @publication.authors.blank? and @publication.journal.blank?
respond_to do |format|
format.js
end
end
現在、私のget_pubmed_data.js.erbテンプレートは単純です
alert('<%= @publication.title %>')
サーバーは次のように応答しています
alert('Evidence for a herpes simplex virus-specific factor controlling the transcription of deoxypyrimidine kinase.')
これは、ブラウザで何も起こらないことを除いて、まったく問題ありません。おそらく、ここで部分的に再現された応答ヘッダーに示されているように、応答のコンテンツタイプが「text/javascript」ではなく「text/html」であるためです。
Status 200
Keep-Alive timeout=5, max=100
Connection Keep-Alive
Transfer-Encoding chunked
Content-Type text/html; charset=utf-8
これはバグですか、それとも何かが足りませんか?ご協力いただきありがとうございます!