$(document).ready(function() { $.ajax({ method: 'GET', url: '/download/attachments/...', dataType: 'text', success: function(data) { var iframe = document.getElementById('result'); iframe = iframe.contentWindow || ( iframe.contentDocument.document || iframe.contentDocument); iframe.document.open(); iframe.document.write(data); iframe.document.close(); } }); });