简体   繁体   English

ajax帮助在php中调用js函数

[英]ajax help calling js function in php

  echo '<script type="text/javascript" src="../play.js">player_update();    creature_update();</script>';

I am trying to make these two scripts run when the data from my ajax files echo it to the screen. 我试图让这两个脚本在我的ajax文件中的数据回显到屏幕时运行。 any help? 任何帮助?

Ex: index.php sends data to .js file then js file sends the information to the servers php file which then returns the above script and runs the functions. 例如:index.php将数据发送到.js文件,然后js文件将信息发送到服务器php文件,然后返回上面的脚本并运行函数。

A script element with a src will ignore the body of the element completely. 带有src script元素将完全忽略元素的主体。

If you want two scripts, then have them in two script elements. 如果您需要两个脚本,请将它们放在两个脚本元素中。

<script src="../play.js"></script>
<script>
player_update();
creature_update();
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM