【问题标题】:Rail5 pdf download with Ajax RequestRail5 pdf 下载与 Ajax 请求
【发布时间】:2016-09-24 06:12:21
【问题描述】:

我有一个 AJAX 调用

$.ajax({
          data: {
              'inward_gate_id': document.getElementById("inward_gate_id_lorry_no").value,
              'called_by': "GENERATEPDF"
          },
          dataType: "script",
          method: 'get',
          success: function (data) {
              window.location.reload();
          }
      });

在我的控制器中

send_data pdf.render, :filename => "report.pdf", :type=>"application/pdf", :x_sendfile => true

登录终端如下

Rendering text template
  Rendered text template (0.0ms)
Sent data report.pdf (0.5ms)

但是没有提示下载pdf

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-5 prawn


    【解决方案1】:

    在初始化器中:

    mime type =>  allow pdf
    

    并从 ajax 发送 pdf 类型请求

    (看Prawn Gem For Pdf

    【讨论】:

    • 已经完成,但没有进行 pdf 下载
    • 在 youtube 上观看一次 prawn gem,如果有问题请告诉我
    猜你喜欢
    • 2016-04-03
    • 1970-01-01
    • 2014-01-16
    相关资源
    最近更新 更多