1

I've the following code working properly which opens a pdf downoloaded in the same window:

jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
    .appendTo('body').submit().remove();

I'd like open the pdf in a new tab or window.. How can I change the appendTo in order to achieve it?

Thanks in advance!!

Héctor Ortiz
  • 257
  • 1
  • 6
  • 17

3 Answers3

1

You can set target="_blank"

jQuery('<form target="_blank" action="' + url + '" method="' + (method || 'post') + '">' + inputs + '</form>')
  .appendTo('body').submit().remove();
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531
1

Add target='_blank' attribute into forms.

target="_blank"
7urkm3n
  • 6,054
  • 4
  • 29
  • 46
0

I think you can use $.ajax or $.post to get pdf url and you can use window.open() to open this url in new tab:)

Yasin
  • 36
  • 4