0

I can't find the reason why the below code is not working. It seems like an ordinary "test" alert, but it does not work!

This is a .php file with the following code:

<?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>

Thanks in advance!

ANSWER:

It appeared there was a bug in my SelectImage file. An element was called which does not exist on this particular PHP file.

1
  • 3
    always use firebug or other, to check, it would show the error Commented Mar 11, 2014 at 20:25

5 Answers 5

5

Your syntax is close, but no cigar. Literally just missing a ). RTM...

$( document ).ready(function() {
Sign up to request clarification or add additional context in comments.

2 Comments

@user2014780 RTFE still applies. Also, I wouldn't gloat about not being able to accomplish an extremely basic web programming task...have you checked your Networking tab to make sure all of your assets downloaded properly to the browser?
It was an issue in the SelectImage file. I put the answer in the main post.
2

In the php code: if(!session->loggedIn) I believe you are missing a $ before session. Ex. if(!$session->loggedIn)

Comments

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

You missed one bracket in your code

Comments

0

the closing bracket is missing after "document" variable. The correct form is

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

Comments

0
<!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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.