0

API経由でJsreportを使用しています。

ブラウザーから、jsreport サーバーに対して ajax 呼び出しが行われます。サーバーは POST で応答し、データと、ファイルの場所を含むヘッダー タグ Permanent-Link を返します。

コピーしてブラウザーに貼り付けて、pdf ファイルを表示できるようにします。

問題は、ajax 呼び出しの成功ハンドラーで自動的に表示したいのですが、xhr.getRespondHeader() は Content-Type 以外のヘッダーを許可しません。応答ヘッダーには、「Access-Control-Allow-Origin: *」が既に含まれています。

ユーザーのためにPDFを取得するにはどうすればよいですか?

4

1 に答える 1

1

You can use official jsreport browser client - http://jsreport.net/learn/browser-client

If it is loaded in the page, opening a report is as simple as this

jsreport.serverUrl = 'http://localhost:3000';

var request = {
  template: { 
    content: 'foo', engine: 'none', recipe: 'phantom-pdf'
   }
};

//display report in the new tab
jsreport.render('_blank', request);

You can also check its source code if you are curious how it is handling AJAX https://github.com/jsreport/jsreport-browser-client-dist

于 2016-07-10T19:08:10.610 に答える