[英]load javascript via ajax
I'm loading the following code via javascript into the website via ajax request: 我通过ajax请求通过javascript将以下代码加载到网站中:
<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. 如果我直接通过浏览器使用此代码调用php文件,则一切正常。 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. 谢谢你,Shilly。 I loaded the var url
itself, without ajax. 我加载了无ajax的var url
本身。 Everything works fine. 一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.