doudang2537 2013-08-31 18:46
浏览 48

如何在codeigniter2.1.3中加载外部javascript.php?

To start this topic off:

This works : php and external javascript

This leads me to believe that there is some way to echo javascript in a file named javascript.php within the applications/controllers folder as then to include the js src = base_url().'javascript.php' in a view.

I would like the added security of my codeigniter application in my js. It makes sense to me in cases where I might edit the csrf token output to store in a session var instead of a cookie and pass it to the script.php from a controller initially and then I'd have to use ajax to get new ones ,but, the script could be more secure and I wouldn't need to use cookies. I have not seen anything like it so far in all of my searches , but, that does not always mean that its impossible or impractical.

  • 写回答

1条回答 默认 最新

  • ds19891231 2013-08-31 19:11
    关注

    If I understand your question you are looking to/would like to output js code to a view from a controller? That is no problem - it's done all the time. If you want to output just javascript then set the correct header('Content-Type: application/javascript') - or you may just want to include javascript in an html page, in which case you can pass the code via $data[] to the view and include it on the served page wherever that suits you? $this->load->view('my_view', $data);

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器