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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T12:57:18+00:00 2026-05-28T12:57:18+00:00

I am using Jquery form plugin to upload file in Ajax request.File is successfully

  • 0

I am using Jquery form plugin to upload file in Ajax request.File is successfully sent to server but on response browser is asking to save response with following popup

enter image description here

Here is my HTML

<form:form name="newRequestForm" id="newRequestForm" modelAttribute="requestForm" method="POST">     
<form:input path="mrnFile" type="file" size="40"/>
</form:form>  

JS

    // Initializing Jquery form 
     $(function() {
        $('#newRequestForm').ajaxForm();   
    });

   // This function is called on click event of submit button  
function submitDataRequest(formAction) {
    var options = { 
            beforeSubmit: showRequest,  // pre-submit callback 
                success: showResponse,  // post-submit callback 
                url:  formAction,
                dataType:  'json'
            }; 
     $('#newRequestForm').ajaxSubmit(options); 
}   


function showRequest(formData, jqForm, options) { 
    alert('About to submit: '); 
    return true; 
} 

function showResponse(data, statusText, xhr, $form)  { 
    Alert("In response..")
    if (!data.actionPassed) {
        showErrors(data.errors);
        $("#hideOrShowErrors").show();  
    } else {
        showConfirmation(data, confirmationMsg, formName, successFormAction);
    }
} 

showResponse is never invoked instead browser shows the popup.
I checked through Firebug, the response code is 200 still success callback is not executed.
After reading some similar question I think it has something to do with server response type. So I did following in my spring controller

public ResponseEntity<ResponseDTO> save(@ModelAttribute("dataRequestForm") DataRequestFormDTO dataRequestFormDTO, BindingResult result, SessionStatus status, Model model, HttpServletResponse response) {  
HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.setContentType(MediaType.APPLICATION_JSON);
        return new ResponseEntity<ResponseDTO>(responseDTO, responseHeaders, HttpStatus.CREATED);
    }   

On both side I have data type as json but still I am getting the popup.Am I making any blunder?

Thanks!


EDIT:

Updated JS

function submitDataRequest(formAction) {
     var options = { 

                  beforeSubmit: function(){ 
                  alert("Before submit");
                  },  // pre-submit callback 
                    success: function(){
                    alert("On success");
                    },  // post-submit callback 
                    url:  formAction
    }  
         $('#newRequestForm').ajaxSubmit(options); 
 }

Still I get the same popup and success callback is not fired.

Added initBinder in controller

@InitBinder
    protected void initBinder(HttpServletRequest request,
            ServletRequestDataBinder binder) throws ServletException {
        binder.registerCustomEditor(CommonsMultipartFile.class,
                new ByteArrayMultipartFileEditor());    
    }   

After adding initBinder I got following error

No serializer found for class java.io.ByteArrayInputStream and no properties discovered to create BeanSerializer
  • 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-28T12:57:19+00:00Added an answer on May 28, 2026 at 12:57 pm

    This is a common issue with IE and iframe (used by jquery form plugin to upload files with ajax).

    I solved in two steps:

    1) Server Side: remove headers, send back just the content.

    2) Client-Side: do not set the ajax request dataType parameter and on success use the following code to extract json:

    success: function(data)
    {
        try{
            jsonData = jQuery.parseJSON(data);
            // continue process with json encoded data
        }
        catch(e)  
        {
            // handle parsing error
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Jquery form plugin to upload file in Ajax request.File is successfully
I'm using the jQuery plugin ajaxForm to submit a file upload form via AJAX.
I'm using the jquery form plugin ( http://malsup.com/jquery/form/ ) to upload a file via
i am using jquery form plugin for file upload . i am not able
I am using jquery form plugin for file upload . my question is how
I've got a simple HTML file upload form. I'm using the jQuery validation plugin
I have file upload using jquery form plugin as $(function() { $(#Form).ajaxForm({ iframe: true,
I'm using the jQuery Form plugin to upload an image. I've assigned a fade
I am getting strange behaviour when trying to upload files, using jQuery multi-file plugin,
I am using the multi-upload plugin found at: http://www.fyneworks.com/jquery/multiple-file-upload/ This is what I am

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.