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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:31:12+00:00 2026-05-19T01:31:12+00:00

I’m trying to upload a file using AJAX, process data in the file and

  • 0

I’m trying to upload a file using “AJAX”, process data in the file and then return some of that data to the UI so I can dynamically update the screen.

I’m using the JQuery Ajax Form Plugin, jquery.form.js found at http://jquery.malsup.com/form/ for the javascript and using Django on the back end. The form is being submitted and the processing on the back end is going through without a problem, but when a response is received from the server, my Firefox browser prompts me to download/open a file of type “application/json”. The file has the json content that I’ve been trying to send to the browser.

I don’t believe this is an issue with how I’m sending the json as I have a modularized json_wrapper() function that I’m using in multiple places in this same application.

Here is what my form looks after Django templates are applied:

<form method="POST" enctype="multipart/form-data" action="/test_suites/active/upload_results/805/">
  <p>
     <label for="id_resultfile">Upload File:</label> 
     <input type="file" id="id_resultfile" name="resultfile">
  </p>  
</form>

You won’t see any submit buttons because I’m calling submit with a button else where and am using ajaxSubmit() from the jquery.form.js plugin.

Here is the controlling javascript code:

function upload_results($dialog_box){
    $form = $dialog_box.find("form");
    var options = {
            type: "POST",
            success: function(data){
                alert("Hello!!");
            },
            dataType: "json",
            error: function(){
                console.log("errors");

            },
            beforeSubmit: function(formData, jqForm, options){
                    console.log(formData, jqForm, options);
                },
        }
    $form.submit(function(){
        $(this).ajaxSubmit(options);
        return false;
    });
    $form.ajaxSubmit(options);
}

As you can see, I’ve gotten desperate to see the success callback function work and simply have an alert message created on success. However, we never reach that call. Also, the error function is not called and the beforeSubmit function is executed.

The file that I get back has the following contents:

{"count": 18, "failed": 0, "completed": 18, "success": true, "trasaction_id": "SQEID0.231"}

I use ‘success’ here to denote whether or not the server was able to run the post command adequately. If it failed the result would look something like:

{"success": false, "message":"<error_message>"}

Your time and help is greatly appreciated. I’ve spent a few days on this now and would love to move on.

  • 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-19T01:31:13+00:00Added an answer on May 19, 2026 at 1:31 am

    In case anyone had a similar problem, here’s the final javascript I ended up using:

    function upload_results_dialog($data_elem){
        var $dialog_box = $("#ajax-dialog-box"),
        data = $data_elem.attr("data");
        $.ajax({
            url: "../upload/" + data+ "/",
            success: function(response){
                $dialog_box.html(response);
                $dialog_box.dialog("option",
                    {
                        title: "Upload",
                        height: 260,
                        width: 450,
                        buttons: {
                            Cancel: function(){
                                $(this).dialog('close');
                            },
                            Upload: function(){
                                upload($(this));
                            }
                        }
                    }
                );
                $dialog_box.dialog('open');
            }
        });
    }
    function upload($dialog_box){
        var $form = $dialog_box.find("form"),
          iframe = $dialog_box.find("iframe"),
          $html = $($iframe.contents()),
          $iframe_form = $html.find("form");
        $iframe_form.html($form.contents());
    
        //Set the onload function
        $iframe.attr("onload","check_file_uploaded_valid()");
        $iframe_form.submit();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.