Build up correct form Data

137 views Asked by At

I am attempting to preform File Upload with Kendo UI. The file is stored in an ECM which I upload to with CMIS utilizing Browser Binding. My original AJAX function which is working is like:

    $.ajax({
        url: 'MY CMIS URL',
        type: 'POST',
        data: new FormData($('#myForm')[0]),
        processData: false,
        contentType: false,
        success: function () {
            alert("Document Uploaded");
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert(xhr.status + " " + thrownError);
        }
    });

So my form has CMIS properties on it - this successfully gets added to my Request when I look at fiddler - as shown:

enter image description here

However now I am using Kendo UI for upload and the code is as below:

    $("#target").kendoUpload({
        multiple: false,
        async: {
            saveUrl: 'MY CMIS URL',
            autoUpload: true,
            withCredentials: false,
        },
        upload: function (e) {
            $('#propertyValue_0_').val(e.files[0].name);
           // e.data = new FormData($('#uploadForm')[0]); - did not work
            var formData = $('#uploadForm').serializeArray();
            e.data = formData;
        }
    });

First I had the data set similar to my AJAX call but this did not work. Doing a serialize and setting e.data = formData; is closer to what I need. When I check the fiddler request I see the below:

enter image description here

If I set a breakpoint in Dev Tools I can see that formData variable contains the array of objects with the name and value as "cmisaction" "createDocument"

enter image description here and the same for the rest of the propeties but instead in my fiddler trace I am geting name="0" and [Object Object] sent.

How can I correctly set e.data to the name and values in formData?

0

There are 0 answers