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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:12:04+00:00 2026-06-05T03:12:04+00:00

I am using ajaxupload.js from here and I see the file doing the upload

  • 0

I am using ajaxupload.js from here and I see the file doing the upload work alright. But I am getting <pre style="word-wrap: break-word; white-space: pre-wrap;">{"id":"006","path":"006.png"}</pre> in the response.

I think the response should be just {"id":"006","path":"006.png"} but for some reasons it got wrapped around <pre> and hence the Uncaught SyntaxError: Unexpected token <.

I am using spring mvc 3, tomcat. I am using java.io.Writer to write the response as writer.write(json.toString());

Could someone help me understand this error and how to resolve it?

Thanks.

UPDATE:

CODE:

<form id="app-form" class="cols" action="#" method="POST">
    <fieldset class="w50">                              
        <!--  set of form fields -->
    </fieldset>   
    <fieldset class="w50">                              
        <button id="uploadButton" class="csbutton-grey" >Upload</button>
        <ul id="locationImages"></ul>
    </fieldset>
<div style="float: left;">
    <button type="submit" class="cool-button">Submit</button>
</div>
</form>


$(document).ready(function(){
    var button = $('#uploadButton'), interval;

    new AjaxUpload(button, {
        action: 'uploadImage', 
        name: 'qqfile',
        responseType: "json",
        onSubmit : function(file, ext){
            this.disable();
            console.log("file - " + file);
            console.log("ext - " + ext);
            if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
                alert('Error: invalid file extension');
                return false; 
            }
            else {
                $.ajax({
                    type:"GET",
                    url:"file",
                    data:'file='+file,
                    success:function(data, textStatus, jqXHR){
                        console.log(jqXHR.status);
                        console.log(data);
                    },
                    error:function(jqXHR, textStatus, errorThrown) {
                        console.log(jqXHR.status);
                    },
                });                 
            }
        },
        onComplete: function(file, response){
            this.enable();
            console.log("file - " + file);
            console.log("response.id - " + response.id + ", response.path - " + response.path);
            $('<li></li>').appendTo('#locationImages').text(file);                      
        }
    }); 
});
  • 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-05T03:12:06+00:00Added an answer on June 5, 2026 at 3:12 am

    Have you set the responseType property as json in AjaxUpload?

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

Sidebar

Related Questions

Possible Duplicate: django file upload from json Hi am using the following ajax upload
i am making an upload with Ajaxupload plugin and i am using this function
I am using jquery ajaxupload plugin to upload files .I have the following js
I'm using the AJAX plugin from Andris Valums: AJAX Upload ( http://valums.com/ajax-upload/ ) Copyright
hii i am using ajax file upload in this code <script type=text/javascript src=fileuploader.js></script> <script
I'm using the jQuery plugin ajaxForm to submit a file upload form via AJAX.
I am using jQuery.Form to upload files on server. Here is an sample I
I'm using Rails and valums file-uploader for ajax upload. In development all works flawlessly,
I am using this ajax file upload script, and all works well in firefox
Want to upload a file using ajax for this using this uploader http://valums.com/ajax-upload/ and

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.