0

Ok i'm trying to build a forum with jquery ajax characteristics. Below is the html/jquery coding. And i know jquery is loaded because I did the alert(1); inside the document ready and it worked.

<!doctype>
<html>
<head>
	<title>Shouts!</title>
	<script src="jquery.js"></script>
	<script>
	$(document).ready(function() {
		$("#messages").load(function('loadchat.php');
		
		$("#post").submit(function(){
		
			return false;
		});
	});
		
	</script>
</head>
<body>
<div id="messages"></div>
<table width="480" BACKGROUND="images/commentback.jpg">
     <tr>
         <td>             
             <form id="post" method="post" action="datetest.php">
              <span class="whitetitle">Name:<br><input name="messages" type="text" STYLE="background: white; border: 1px #000000 solid;"><br >
              <input type="submit" value="send">
              </form>
         </td>
     </tr>
</table>
</div>
<br><br>
</body>
</html>

Below is the php load I'm using to load my database info. I've ran this without jquery and it works fine but I want it to load in messages id. Do I have to so something different when i integrate php and jquery that I'm not aware of?

<?php

include 'config2.php';
$dbname = 'test';
$tablename = 'time';
include 'opendb.php';

$res = mysql_query("SELECT timestamp, message FROM time ORDER BY timestamp DESC LIMIT 0,10;");

while ( $row = mysql_fetch_array($res) ) {
	echo $row["message"] . "<br />";
	echo $row["timestamp"] . "<br />";
	echo date("g:i a F j, Y ",  $row["timestamp"] ) . "<br /><br />";
}
?>
3
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by xylude
0

Do you receive an error when you load up the page or does it still display ?

I think the problem might just be the jQuery. I don't really understand what you're trying to do with .load(function('loadchat.php')). Try the following :

<!doctype>
<html>
<head>
<title>Shouts!</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function() {
$("#messages").load('loadchat.php');
 
$("#post").submit(function(){
 
return false;
});
});
 
</script>
</head>
<body>
<div id="messages"></div>
<table width="480" BACKGROUND="images/commentback.jpg">
<tr>
<td>
<form id="post" method="post" action="datetest.php">
<span class="whitetitle">Name:<br><input name="messages" type="text" STYLE="background: white; border: 1px #000000 solid;"><br >
<input type="submit" value="send">
</form>
</td>
</tr>
</table>
</div>
<br><br>
</body>
</html>

Edited by cuonic: n/a

0

I'm trying to load the data that I have in my database (test1, test2) in the div messages. loadchat.php works alone without jquery

localhost/loadchat.php

but doesn't work when i'm loading it to jquery.

0

$("#messages").load(function('loadchat.php'); should be $("#messages").load(function('loadchat.php'));

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.