I'm loading the following code via javascript into the website via ajax request:
<div class="modal-body" id="modal-body">
<?php
echo $this->Html->script('pdfobject');
?>
<div id="showdoc" style="width: 100%; height: 500px; /*border: 1px solid black;*/">
<p><?php echo __('It appears you don\'t have Adobe Reader or PDF support in this web browser. ').$this->Html->link(__('Click here to download the file'), array('action' => 'getFile', '?' => array('id' => $data['Voucher']['id'], 'download' => true)), array()); ?></p>
</div>
<script type="text/javascript">
window.onload = function (){
var myPDF = new PDFObject({
url: "<?php
echo $this->Html->url(
array(
'controller' => 'vouchers',
'action' => 'getFile',
'?' => array(
'id' => $data['Voucher']['id']
//'download' => 'true'
)
),
true
);
?>",
pdfOpenParams: {
navpanes: 0,
toolbar: 0,
statusbar: 0,
view: 'FitBH,0',//'FitH,0', "FitV"
scrollbars: '1',
messages: '0'
}
}).embed("showdoc");
};
</script>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
Unfortunately, the code is not executed. If I call the php file with this code via browser directly, everything works fine. I expect the problem is, that the code is not executed because the base page is already loaded. Any hints or ideas?
Thank you Shilly. I loaded the var url
itself, without ajax. Everything works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.