Promise returning undefined

后端 未结 4 1681
醉话见心
醉话见心 2020-12-21 09:39

I am trying to use promise to send an ajax request to a php script which checks if a file exist on the server and returns a boolean value.

I have the below code but

4条回答
  •  别那么骄傲
    2020-12-21 10:04

    This part of your code:

    promise.then(function(e) {
        return e;
    });
    

    only returns e to the callback function. You have to handle the result within that callback.

    promise.then(function() {
        // handle result;
    });
    

    Or might as well return the promise as shown by @Ole.

提交回复
热议问题