Jquery ajax contentType: false without making a border tag for jquery ajax

I added contentType as false for my jQuery ajax request. I am sending

$.ajax({
        url : "http://groc.cloudapp.net:8000/api/view/"+tile_vert_id+"/"+tileId,
        type: "PUT",
        data :updatedemoData,
        processData: false,
        cacheControl: "no-cache",
        contentType: false,
        success : function(data,textStatus,jqXHR)
        {
            alert("Yo");
            console.log("successdata: ",data);
            $($caseToEdit).find(".tile-name").text(updatedemoData.name);
            $($caseToEdit).find(".tile-des").text(updatedemoData.description);
            $($caseToEdit).find(".v-url").text(updatedemoData.url);
            $(".ajax-loader").hide();


        },
        error : function(jqXHR,textStatus,errorThrown){
            $(".ajax-loader").hide();
            alert("error in loading!");
        }
    });

and I am sending a Formdata object for data

var updatedemoData = new FormData();
        updatedemoData.name = demoName;
        updatedemoData.description = demoText;
        updatedemoData.videoordemo = tileType;
        updatedemoData.url = demoUrl;

but when I run the same code in the browser console, I get a border tag. Without a boundary tag, data is not stored on the server.

I expect something similar with a border tag

Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryiBHhkxeJP2Vc7a5Q

but the content type is actually

Content-Type:application/x-www-form-urlencoded; charset=UTF-8

Any suggestions

+4
source share
1 answer

In any case, I can make it work when I change the above URL in a local variable.

var ajaxUrl = "http://groc.cloudapp.net:8000/api/view/"+tile_vert_id+"/"+tileId,

$.ajax({
    url : ajaxUrl ,
    type: "PUT",
    data :updatedemoData,
    processData: false,
    ... 
});

URL- , . , .

+2

Source: https://habr.com/ru/post/1583794/


All Articles