robert trudel
robert trudel

Reputation: 5779

Get return function value in promise

I use javascrip and promise.

I search a way to get return value where xxxx is wrote, is there a way to get it

jQuery.ajax({

    success: function(data, status, jqXHR){

        const promise = requestUpdated(data.poviderId);

        promise.then(function(data_tt) {
            return updateAircrafts(data.sspId, data.id); //result 
        }).then(function() {
            //xxxx
            transForm.deserialize("#form", data);
        }).catch(function(error) {
        });

    },
    error: function (jqXHR, status) {

    }
});

Upvotes: 0

Views: 61

Answers (1)

Ariel Salem
Ariel Salem

Reputation: 357

You need to pass in the argument in order to obtain it. This parameter will be the data that's being returned in the then statement beforehand:

jQuery.ajax({

    success: function(data, status, jqXHR){

        const promise = requestUpdated(data.poviderId);

        promise.then(function(data_tt) {
            return updateAircrafts(data.sspId, data.id); //result 
        }).then(function(result) {
            // console.log(result);
            transForm.deserialize("#form", data);
        }).catch(function(error) {
        });

    },
    error: function (jqXHR, status) {

    }
});

Upvotes: 1

Related Questions