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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:48:11+00:00 2026-06-08T04:48:11+00:00

Is it possible to do an AJAX form submit without jQuery or IFrames (so

  • 0

Is it possible to do an AJAX form submit without jQuery or IFrames (so just pure JavaScript)? I’m currently sending to a struts fileUploadAction that works. Would the action’s code still work with the asynchronous submit, or are there additions required to pick up the async form submit?

I am using struts 1.x and current my form is:

<html:form action="fileUploadAction" method="post" enctype="multipart/form-data">
    ...form elements...
    <html:file property="theFile" />
    ...other elements...
</html:form>

Can this form be submitted, and thus the file uploaded with AJAX?

  • 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-08T04:48:13+00:00Added an answer on June 8, 2026 at 4:48 am

    If I understood you correct, you can use the following code to upload the file async. Modify it as you like

    var AjaxFileUploader = function () {
        this._file = null;
        var self = this;
    
        this.uploadFile = function (uploadUrl, file) {
            var xhr = new XMLHttpRequest();
            xhr.onprogress = function (e) {
                ...
            };
    
            xhr.onload = function (e) {
                ...
            };
    
            xhr.onerror = function (e) {
                ...
            };
    
            xhr.open("post", uploadUrl, true);
    
            xhr.setRequestHeader("Content-Type", "multipart/form-data");
            xhr.setRequestHeader("X-File-Name", file.name);
            xhr.setRequestHeader("X-File-Size", file.size);
            xhr.setRequestHeader("X-File-Type", file.type);
    
            xhr.send(file);
        };
    };
    
    AjaxFileUploader.IsAsyncFileUploadSupported = function () {
        return typeof (new XMLHttpRequest().upload) !== 'undefined';
    }
    
     if (AjaxFileUploader.IsAsyncFileUploadSupported) {
            ajaxFileUploader = new AjaxFileUploader();
    
            $("form").submit(function () {
                var uploader = $("#fileUploader")[0];
    
                if (uploader.files.length == 0) {
                    return;
                } else {
                    ajaxFileUploader.uploadFile(
                        "/YourUploadUrl",
                        uploader.files[0]);
                }
    
                return false;
            });
        }
    

    To upload the form use the FormData class, populate it with form values and post it with XHR.

    Update:
    For HTML4 try the following

    • http://www.albanx.com/?pid=5&subid=21
    • Asynchronous file upload (AJAX file upload) using jsp and javascript
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: jQuery AJAX submit form I have a form on a page A,
I am making a jQuery Ajax form submit to a PHP page that I
Is it possible to submit a form with jquery without explicity having to set
I want to use jQuery to submit my form and i can do that
Possible Duplicate: Passing JavaScript Array To PHP Through JQuery $.ajax I'm trying to pass
Possible Duplicate: jQuery/Javascript function to clear all the fields of a form I need
Is this possible to use Ajax.Beginform with update target inside of ajax form. like
Possible Duplicate: return AJAX callback return I have made a JQuery code using AJAX,
Possible Duplicate: JQuery ajax cross domain I need to load content from another websites
Is it possible to combine Ajax post with jQuery UI dialog? And I want

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.