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

  • SEARCH
  • Home
  • 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 6338813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:31:17+00:00 2026-05-24T19:31:17+00:00

I have created a function to upload a file using this library as follows:

  • 0

I have created a function to upload a file using this library as follows:

new AjaxUpload($('#addImage'), {
                action: 'SaveDataBank.aspx',
                name: 'uploadimage',
                dataType: 'json',
                params: { clientid: GetSelectedClient() }
                onSubmit: function (file, ext) {
                },
                onComplete: function (file, response) {
                }
            });

I would like to perform some task before opening a file dialog. How could I update the above code?

UPDATE:

I would like to pass a parameter dynamically with the file upload. I have a dropdown containing a list of client ids. If I click on the Upload button it will open File Dialog. I would then like it to pass in the selected client from the dropdown. Currently, it only passes the initially selected value.

params: { clientid: GetSelectedClient() },

The above line does not work as per my requirement.

  • 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-24T19:31:19+00:00Added an answer on May 24, 2026 at 7:31 pm

    First idea (which doesn’t work)

    Try binding a click handler to the button. If you don’t return false or stop propagation, it will trigger the file uploader after the click handler finishes:

    $('#addImage').click(function(){
        // code here
    });
    
    new AjaxUpload($('#addImage'), {
                    action: 'SaveDataBank.aspx',
                    name: 'uploadimage',
                    dataType: 'json'
                });
    

    This doesn’t work because the AjaxUpload library creates an input element which it puts over the top of the button when you hover over the button. It’s actually the input element that you click.

    Work around

    Bind to the click event of the input that you actually click on. This does not exist on page load, so we have to use the jQuery live function:

    new AjaxUpload($('#addImage'), {
                    action: 'SaveDataBank.aspx',
                    name: 'uploadimage',
                    dataType: 'json'
                });
    
    $('input[type="file"]').live('click', function(e){
        // code here
    });
    

    See my updated fiddle for a working example.

    Passing dynamic data

    To pass dynamic data along with your file upload, add a setData call in the onSubmit handler:

    new AjaxUpload($('#addImage'), {
                action: 'SaveDataBank.aspx',
                name: 'uploadimage',
                dataType: 'json',
                onSubmit: function (file, ext) {
                    this.setData({clientid: GetSelectedClient()});
                }
            });
    

    Conclusions

    This shows that the library is a bit awkward to work with. You don’t click the button, so you won’t get normal button effects (i.e. it becoming indented when mouse down). Any JavaScript which relies on the button events will not work as expected. You can go with the above solution, but personally, I would look for a different library. Maybe the newer one that replaces this? Here are a bunch of others and some more.

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

Sidebar

Related Questions

I have this form to upload an xml file to server, I am using
I have created a function outside of $(document).ready() , but am still using jQuery
i have created a module with this among others this function in it: <?php
I have dialog created like this $('#add_error').click(function(e) { $('<div>') .load('/someaction/format/html/') .dialog({ title: 'Some title',
I have xml file with collection image urls and I want upload this url
I am trying to implement file upload functionality on my site. I have created
I have created a php file that exports data to an excel file using
I have created a function that takes a SQL command and produces output that
I have created a function in PHP that calls a webservice and parses through
in my data layer class I have created a function to manually refresh the

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.