I'm trying to find a solution to return data from ajax response with no possibility to execute a given callback function.
The following code is fix (third party api script) and the only thing i can control is the content of myfunction
:
var myfunction( param ) {
$.get( '/search', { q: param } );
// no further ideas :D
return; // <-- idealy the response of the ajax call
};
Promise.resolve()
.then(
function() {
return myfunction( param );
}
).then(
function( res ) {
return somefunction( res );
}
).catch(
function( res ) {
return errorfunction( res );
}
);
The content of myfunction is by now a ajax call wich performs a database search.
Since I can't use a callback function I'm stuck there. I realy don't want to set the async
option of $.ajax to false.
Any ideas?