• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open PDF file by AJAX holding the button  RSS feed

James Thraloc
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can you help me with the following problem?

I have a form where you select the parameters to generate a PDF report that will be returned by a Struts 1.x action that will be opened by the browser. This is working perfectly synchronously in the system.

But what I need to protect the system from the user is requesting the report without having done all the time, putting a lock on the button to be enabled only once the report was generated.

My choice was to create a function in AJAX (asynchronous call) to which this report was generated, and while this process does not answer me back I hide the button and show the "loading" and so has the return button I show and hide the "loading".

But I'm having problems in two different trials:

In the first attempt (code 1) with jQuery behavior of the button and the loading are expected but my PDF file that returns the function (data) below does not open in browser download window:

On the second try (code 2) using Dojo return the PDF file is expected but when the browser's download window opens lose control in order to enable the button again and disable image loading.

Is there any way to open this PDF file using jQuery or Dojo in control my DIVs?

Thank you,

HTML Fragment:

Code 1 (jQuery):

Code 2 (Dojo):

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!