Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Merge data from many AJAX requests
function aj( url ){
return $.ajax({
url: url,
success: function( data ){
function resolve( args ){
//Create call $.when( url1, url2, url3 )
var defer = $.when.apply( $, $.map( args, aj ) );
return defer.pipe(function(){
//Return data instead of success arguments
// (data,status,browser ajax obj)
return $.map( arguments, function( n, i ){
return n[0];
.then(function( url1data, url2data, url3data ){
//Will map to console.log above
console.log( 'then', arguments );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.