Click here to Skip to main content
11,637,176 members (69,235 online)
Rate this: bad
good
Please Sign up or sign in to vote.
i have this javascript code
var name=$('#element_name').val();
    var ofile=document.getElementById('image').files[0];
    var formdata;
        if(FormData)
        {
            formdata=new FormData();
            formdata.append("image",ofile);
        }
    formdata.append("element_name",name);
    $.ajax({
        url:'elements/save_elements',
        data:formdata,
        type:'POST',
        success:function(res)
        {
            $('#response').html(res);
        },
        error:function(xhr,rrr,error)
        {
            alert(error);
        }
    });

this code gives the error same as the title of the question.
what do i do?
Posted 31-Oct-13 22:27pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Set this parameter to false i.e. processData: false in your script where you are sending your form data.
processData (default: true)

Type: Boolean

By default, data passed in to the data option as an object (technically, anything other than a string) will be processed and transformed into a query string, fitting to the default content-type "application/x-www-form-urlencoded". If you want to send a DOMDocument, or other non-processed data, set this option to false.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 jyo.net 295
2 stibee 288
3 himanshu agarwal 184
4 Sergey Alexandrovich Kryukov 184
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,513
2 Mika Wendelius 6,922
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web01 | 2.8.150728.1 | Last Updated 21 Oct 2014
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100