我不确定是否可以在JavaScript函数中运行PHP系列.例如:
<script language=javascript>
var int=self.setInterval("message()",1000);
function message()
{
<?PHP mysql_query("SELECT * FROM example"); ?>
}
</script>
Run Code Online (Sandbox Code Playgroud)
我没有尝试过这个,但我认为你不能像这样运行PHP.有谁可以帮忙.我可以在javascript函数中以某种方式运行PHP脚本而无需通过Ajax调用外部PHP文件吗?