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 9017107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:10:51+00:00 2026-06-16T04:10:51+00:00

When I click a button on the client side I want to invoke a

  • 0

When I click a button on the client side I want to invoke a public static webmethod on the server side using AJAX. The static method will create the appropriate file. After the file is created I need to download it to the client desktop. I’ve found John Culvinar’s jquery filedownload plugin but haven’t been able to implement it so far. I know that using this plugin also requires writing a cookie so that it knows that the download is complete. Where do I put this code in the server side? After creating the file? I’d be very glad if someone could show me a sample on this scenario, maybe on jsfiddle.net

  • 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-06-16T04:10:52+00:00Added an answer on June 16, 2026 at 4:10 am

    I suggest replacing your ajax request with a hidden iframe, then when your server returns said file, it will automatically ask the user to download it.

    //name of iframe
    var strName = ("uploader" + (new Date()).getTime());
    // the iframe
    var jFrame = $( "<iframe name=\"" + strName + "\" src=\"about:blank\" />" ).css( "display", "none" );
    
    jFrame.load(function( objEvent ){     
        // at this point the user should have been asked to download a file.
    
        // Remove the iFrame from the document.
        // Because FireFox has some issues with
        // "Infinite thinking", let's put a small
        // delay on the frame removal.
        setTimeout(function(){
            jFrame.remove();
        },100);
    });
    
    var form = $('<form>').attr( "action", "upload_act.cfm" )
        .attr( "method", "post" )
        .attr( "enctype", "multipart/form-data" )
        .attr( "encoding", "multipart/form-data" )
        .attr( "target", strName );
    
    form.append('<input type="hidden" name="somename">').val("someval");
    
    $( "body:first" ).append( jFrame, form );
    

    (The above code was original adapted from http://www.bennadel.com/blog/1244-ColdFusion-jQuery-And-AJAX-File-Upload-Demo.htm)

    An alternative would be to make it a two step process. Step 1 generates the file and returns a url, step 2 the user clicks download ( which would be an anchor tag pointing at said url).

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

Sidebar

Related Questions

I want to fire a server-side ASP.NET button click event in JavaScript. I checked
On the client side, if user click a button I want take user to
I want to call jQuery function from server. The server side button that calls
i want to send a file from client to server. My code: Client side
my problem is this: i want to create a server control that inherits System.Web.UI.WebControls.Button
I have Client-Side button event. After click call sgnPdf(ID) if I can sign PDF.
On my aspx page I dynamically create html controls on client side using javascript.
How to disable button callback, I want to use this button on client side
I am using an MVC 3 Ajax.BeginForm call for form submission with client side
click the button to call this method: private void goRegister(final boolean isUsername) { new

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.