Probleem met javascript/jquery en mySQL/PHP

Status
Niet open voor verdere reacties.

Stabiloy

Gebruiker
Lid geworden
3 okt 2009
Berichten
129
Hallo,

Heb onderstaande code om een shoutbox op mijn site te plaatsen. Echter wilt de submit functie niet werken. Hoop dat één van jullie mij op weg kan helpen.
chatlist.php
PHP:
$act = $_GET['act'];
	if ($act == "add"){
	  $nick = $_GET['nick'];
	  $msg = addslashes($_GET['msg']);
	  $sql = "INSERT INTO Forum_Shout (naam, shout, datum)
				   VALUES ('".$nick."','".$msg."','".time()."')";
	  $qry = mysql_query($sql)or die("fout");
	}
	$sqlLoad = "SELECT * FROM Forum_Shout ORDER BY datum DESC LIMIT 0,20";
	$qryLoad = mysql_query($sqlLoad);
	$rsLoad = mysql_fetch_array($qryLoad);
	
	echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">';
	do{
		$i++;
		$u = $i % 2;
		if($u != 0)
		{
			$bg = ' bgcolor="#CCCCCC"';
		}
		else
		{
			$bg = '';
		}
		echo '
			<tr valign="top"'.$bg.'>
				<td>'.$rsLoad['naam'].'</td>
				<td>
					<img src="http://www.bryantan.info/uploads/jquerysamples/bullet.gif" />
				</td>
				<td>
					' .$rsLoad['shout'] . '<br />
					<span class="date">'.date('H:i:s Y-m-d',$rsLoad['datum']).'</span>
				</td>
			</tr>';
	
	}while($rsLoad = mysql_fetch_array($qryLoad));
	echo '</table>';
shout.php
HTML:
<div id="chatbox">
    <form id="form">
    	<input type="hidden" value="<? echo $_SESSION["GyntoNaam"]->naam;?>" id="nick"/>
        <table>
            <tr>
                <td><label>Shout:</label></td>
                <td><input id="message" type="text" maxlength="255"/></td>
                <td><input id="send" type="submit" value="Shout it!" /></td>
            </tr>
        </table>
    </form>
	<div id="ajax">
    	<div class="acontent">
    		<div id="msg">
    
    		</div>
  		</div>
	</div>
</div>
En tot slot het javascript/jquery gedeelte.
[JS] $(document).ready(function(){

updateChatbox = function updateChatbox(){
$.ajax({
type: "POST",
url: "Includes/chatlist.php?",
data: "act=update",
cache: false,
success: function(html){
$('#msg').html(html);
}
});
}

updateChatbox();

$("#form").submit(function() {
nick = $('#nick').val();
msg = $('#message').val();
$.ajax({
type: "POST",
url: "Includes/chatlist.php",
data: "act=add" + "&nick=" + nick + "&msg=" + msg,
cache: false,
success: function(html){
$('#msg').html(html);
}
});
$('#message').val(""); // reset the value
return false; // return false to prevent loading the page
});

setInterval(updateChatbox, 1000 );
});[/JS]

Het updaten om de 1sec werkt op dit moment wel..
 
Status
Niet open voor verdere reacties.

Nieuwste berichten

Terug
Bovenaan Onderaan