J'ai un bouton d'impression dans un modal bootstrap.Comment appeler window.print sur la page html renvoyée après un appel ajax
$('#printST').click(function() {
$.ajax({
type: 'GET',
url: 'print',
data: formData,
dataType: 'html',
success: function (html) {
// how to print the content of html?
},
error: function (data) {
console.log('Error:', data);
}
});
});
Je souhaite imprimer les données renvoyées.
Dans ma page d'impression
<script type="text/javascript">
window.onload = function() { window.print(); }
Dans mon contrôleur
...
return View::make('pages.print');
Comment puis-je imprimer le contenu de ces pages après appel ajax?
bien vous devez l'ajouter à la page pour l'imprimer. – epascarello
@epascarello Comment puis-je retourner la page html dans un appel ajax? La fonction print() est déjà là. – Crazy
pourquoi ne l'ouvrez-vous pas simplement dans une nouvelle fenêtre? Charger une page avec Ajax ne fait rien, c'est du texte brut. – epascarello