await for jQuery.when ajax requests
问题 This code inside async function, does not give the expected result: var result = await $.when( $.get('/api/1'), $.get('/api/2') ); with one request, result will be the output I expect (the response text). However, with these two requests, the returned result is an array which does not hold the two Promises values. Is there any workaround? I know there are then() and done() , but I prefer using await. 回答1: jQuery's .when() and the native await have different semantics. Compare: // jQuery $