I'm struggling with an ajax GET using a promise. If the ajax runs into an error, such as the URL is incorrect, the 'error: function ()' is called and I get an error in the browser debug saying "Uncaught (in promise) undefined"
The first two parts of the ajax function works OK i.e. if the ajax returns a success, then both inner conditions for result.success true/false are working, I just don't know how to resolve the reject call in the ajax error function at the bottom:
    var myVariable = "test";
    let promise = myFunction(myVariable);
    
    promise.then(function () {
        // Do Something           
    }).catch(function (message) {
        console.error(message);
    });     
    function myFunction(myVariable) {
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: "GET", //send it through get method
            url: "/myURL/Edit?handler=GetBlahBlah",
            data: {
                sourceType: myVariable
            },
            contentType: "json",
            dataType: "json",
            success: function (result) {
                if (result.success == false) {
                    reject(result.responseText); // This works
                } else {
                    resolve(); // This works
                }
            },
            error: function () {
                reject("Error while making Ajax call! Get Trigger"); // NOT WORKING!!
            }
        });
    });
}
