1

Okay, so I'm trying to make a simple content loader which will evolve into a chat program. As of now I can't even get Jquery's .load() function to work though.

This is the important part my main file:

<script type="text/javascript">
        $(document).ready(function(){
            $("#messages").load('/ajax-chat-load.php');
        });
    </script>

<div id="#messages">[No messages]</div>

And this is whats in /ajax-chat-load.php

echo "Hotdogs are tasty";

Now if my understanding is correct it the main file should call ajax-chat-load.php to load the html inside that to the #messages div when the document is done loading. But the #messages div just keeps the message [no messages].

2 Answers 2

2

# represents id. you can not use it as id = '#messages'

change your code to this:

<script type="text/javascript">
        $(document).ready(function(){
            $("#messages").load('/ajax-chat-load.php');
        });
    </script>

<div id="messages">[No messages]</div>

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

1

You don't put a # in front of the id in html. So do your messages div like this:

<div id="messages">[No messages]</div>

Your jQuery code looks fine (you do put a # in front of the id in the css path you pass to jQuery).

1 Comment

Oh, wow. Duh, I'm so stupid rofl. Thank you for pointing that out. I can't believe I didn't notice that before posting:< lol

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.