Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have this javascript code
JavaScript
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

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900