PHP文件中的JavaScript没有输出任何东西


JavaScript in PHP file not outputting anything

我找不到下面代码不工作的原因。这似乎是一个普通的"测试"警报,但它不起作用!

这是一个.php文件,代码如下:

<?php 
require_once('../../usefull/functions');
if(!session->loggedIn)
{ redirect_to("../index.php"); }
?>
<link href="../ssheet.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../scripts/Image.js"></script>
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
    alert("hello");
});
</script><?php
<div id="imagelist"></div>

提前感谢!

答:

我的SelectImage文件中出现了一个bug。

您的语法很接近,但没有雪茄。只是少了a)。RTM…

$( document ).ready(function() {

在php代码中:if(!session->loggedIn)我相信您在会话之前缺少$。前女友。if(!$session->loggedIn)

$(document).ready(function() {
    alert("hello");
});

你的代码中少了一个括号

"document"变量后面缺少右括号。正确的形式是

$(document).ready(function(){
    alert("hello");
});
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
 <script>
  $(document).ready(function(){
   alert('Hello');
  });
</script>
</head>
<body>
</body>
</html>