Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 655847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:38:58+00:00 2026-05-13T22:38:58+00:00

I have a controller (Spring-MVC) that generates a PDF report on a get request.

  • 0

I have a controller (Spring-MVC) that generates a PDF report on a get request. The controller sets headers like “application/OCTET-STREAM”, “Content-Disposition”, “attachment; filename=\”” + filename + “\”” so that the user gets the save/open dialog forced to them. The controller gets a pdf generated and writes the pdf bytes directly to the response’s output stream. The ModelAndView that is returned is null.

The issue is I need/want to disable the button that generates the report request after it is clicked and then re-enable it when the report is finished in order to prevent double clicking.

I thought I could use prototype.org’s Ajax.Request to do this… This bit of code does work the buttons properly but then I’m stuck because the client never gets the pdf. I’m guessing I need to do something with the response but I don’t know what. Any ideas/help is appreciated.

function displayPdf(button_b, pdf_url) {
   button_b.disabled = true;
   new Ajax.Request(pdf_url, {
       asynchronous:true,
       evalScripts:true,
       method:'get',
       onComplete: function(response) {
         button_b.disabled = false;
      },
      onFailure: function() {
          redAlert('crap');
     }
   });
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:38:59+00:00Added an answer on May 13, 2026 at 10:38 pm

    The best way I can think to accomplish everything that you want, assuming that you’re still forcing a download would to be something like this I think:

    <html>
    <head>
        <script>
            function get_it() {
                document.getElementById('the_button').disabled = true;
                document.getElementById('the_frame').src = "http://www.ca3.uscourts.gov/opinarch/063575p.pdf";
            }
            function enable_button() {
                document.getElementById('the_button').disabled = false; 
            }
        </script>
    </head>
    <body>
        <iframe id='the_frame' onload='enable_button()'></iframe>
        <button id='the_button' onclick='get_it()'>Get it</button>
    </body>
    </html>
    

    Basically, you’re telling it to send it to the iframe instead of using an AJAX request. Once the pdf is ready, the iframe’s onload event will fire, re-enabling the button. You’ll probably want to use actual event listeners for this as opposed to the deprecated inline ones that I’ve used in the example 😛

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You probably want to call setlocale() first, "LC_ALL" should do… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Linux Ubuntu Desktop Jaunty Firebug FireCookie Pixel Perfect Web developer… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Your code should look like this: var par = [];… May 14, 2026 at 9:06 am

Related Questions

I'm using a very simple MVC framework, Bear Bibeault's Front Man , which, for
I'm new to MVC, and am not following how you'd do paging and sorting
Here is the idea: When the user wants to see /controller/action, then I want
If I have an Action like this: public ActionResult DoStuff(List<string> stuff) { ... ViewData[stuff]
I'm having some trouble with ASP.NET MVC Beta, and the idea of making routes,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.