在text html模版中写js,Rails3使用text/html内容类型而不是text/javascript呈现js.erb模板...

我正在使用3.0.0.beta3构建一个新的应用程序.我只是尝试将js.erb模板呈现给Ajax请求以执行以下操作(在publications_controller.rb中):

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('')

服务器正在响应以下内容

alert('Evidence for a herpes simplex virus-specific factor controlling the transcription of deoxypyrimidine kinase.')

不同之处在于没有在浏览器中发生的,可能是因为内容类型的响应是不是如图这里部分转载响应头"文/ JavaScript的""text/html的",这是完美的罚款:

Status 200

Keep-Alive timeout=5, max=100

Connection Keep-Alive

Transfer-Encoding chunked

Content-Type text/html; charset=utf-8

这是一个错误还是我错过了什么?谢谢你的帮助!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值