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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:55:41+00:00 2026-06-15T14:55:41+00:00

I have an Ajax file upload with this code: $(‘#photo-input:file’).change(function() { var photo =

  • 0

I have an Ajax file upload with this code:

$('#photo-input:file').change(function() {
                var photo = this.files[0];
                var caption = $('.photo-caption').val();
                type = photo.type;
                if (photo.type != 'image/png' && photo.type != 'image/jpg' && !photo.type != 'image/gif' && photo.type != 'image/jpeg' ) {
                    alert('Sorry, you may only upload png, jpg, jpeg, or gif images.');
                    return false;
                }

                $('.photo-post-submit').click(function () {
                    var formData = new FormData();
                    formData.append('photo', photo);
                    $.ajax({
                        url: '/post',
                        type: 'POST',
                        data: {'photo' : formData, 'caption' : caption},
                        cache: false,
                        contentType: false,
                        processData: false,
                        success: function () {
                        }
                    }, 'json');
                });

            });

But when I call request.POST['caption'] or request.POST['photo'] I get the error:

Not an HTML form submission (Content-Type: application/xml)

What’s going wrong?

  • 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-15T14:55:42+00:00Added an answer on June 15, 2026 at 2:55 pm

    It looks as if you got confused between the $.post and $.ajax methods, since you are passing in a separate json argument (which $.ajax doesn’t accept as a dataType argument).

    Moreover, you really should not set the contentType to false, and you are setting processData to false, making for a very confusing mix as to what Pyramid will have to do with whatever jQuery makes of that combination.

    To POST to a server with the cache parameter set to false, use:

    $.ajax({
        url: '/post',
        type: 'POST',
        data: {'photo' : formData, 'caption' : caption},
        cache: false,
        dataType: 'json',
        success: function () {
        }
    });
    

    Note that the dataType is set to json, which means your Pyramid view needs to return JSON, the jQuery AJAX code is expecting a JSON response.

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

Sidebar

Related Questions

I have this ajax/jquery code : var headline = $(input#headline).val(); var subheadline = $(textarea#subheadline).val();
I am trying to upload files using AJAX to ASP.NET. I have this Javascript:
I have an ajax.php file in my Wordpress themes folder, and this was working
I have an AJAX function inside a javascript file and I want it to
I have Ajax file in which code has written to accept values form user
I'm using a flash/ajax file upload in php based on this site - http://blog.codeville.net/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/
I have a working Ajax form, now I'm trying to add file upload to
I have a function that searches a database table via ajax. This is the
So I have ajax file upload partial (using Jquery Form plugin), it's working perfectly,
I have this code. <html> <head> <script src=//ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js> </script> <script> Event.observe('clickme', 'click', function(event) {

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.