/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$.when( $.getJSON('/some/data/'), $.get('template.tpl') ).then(function( data, tmpl ){ $( tmpl ) // create a jQuery object out of the template .tmpl( data) // compile it .appendTo( "#target" ); // insert it into the DOM });
URL: http://stackoverflow.com/questions/4869609/how-can-jquery-deferred-be-used