Click here to Skip to main content
12,510,860 members (58,685 online)
Rate this:
 
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160929.1 | Last Updated 21 Oct 2014
Copyright © CodeProject, 1999-2016
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