dongren1977 2012-07-10 06:55
浏览 52
已采纳

从javascript调用php作为src文件

i have a question when a .php file called as a javascript what dose this mean? and when this is needed to be used ?

ex:

<head> 
<script src="dir/myphpfile.php" type="text/javascript"></script>
</head> 
  • 写回答

2条回答 默认 最新

  • dongwo5110 2012-07-10 06:57
    关注

    This means that the myphpfile.php would generate javascript code as output instead of HTML because that's all that the web browser could understand in a script tag. It is useful in situations when you want to generate dnyamic javascript at runtime instead of statically coding it in a separate .js file. Think for example declaring a javascript variable containing the list of customers stored in a database on the server and making this javascript variable globally accessible.

    Another common example where this could be useful is to implement JSONP allowing cross domain AJAX requests.

    Yet another example is to use a php script that will combine and cache the output of multiple javascript files into one.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用三极管设计一个单管共射放大电路
  • ¥20 fluent无法启动
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架