I am trying POST ajax call to my back end.
It is working fine if I set async: false, but if I remove that it is failing and return undefined in error section
 $.ajax({
        type: "POST",
        enctype: 'multipart/form-data',
        url: "http://localhost:8000/student/queue/create",
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        success: function (data) {
            console.log("SUCCESS : ", data);
        },
        error: function (e) {
            console.log("ERROR : ", e.responseText);
            alert("ERROR : "+  e.responseText);
        }
    });
Calling my ajax function from button onclick
<button type="submit" id="submit-createqueue" class="btn feedback glass" onclick="sendformDataToBackend()">Submit</button>
I tried Ajax Call returns undefined when async is true but that also not working
function Call(data) {
    return $.ajax({
        url: "http://localhost:8000/student/queue/create",
        type: "POST",
        enctype: 'multipart/form-data',
        data: data,
        processData: false,
        contentType: false,
        cache: false,
        timeout: 600000,
        error: function (e) {
        console.log("ERROR : ", e.responseText);
        alert("ERROR : "+  e.responseText);
        }
    });
}
Call(data).then(function(data) {
    console.log(data);
    alert("test")
});
 
    