Deferred with $.when help and template example


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $.when( $.getJSON('/some/data/'), $.get('template.tpl') ).then(function( data, tmpl ){
  2.  
  3. $( tmpl ) // create a jQuery object out of the template
  4. .tmpl( data) // compile it
  5. .appendTo( "#target" ); // insert it into the DOM
  6.  
  7. });

URL: http://stackoverflow.com/questions/4869609/how-can-jquery-deferred-be-used

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.