1 Dernière modification par pacphil (02-03-2016 16:52:07)

Sujet : envois via jquery vers php ne fonctionne pas?

Bonjour, j'ai un soucis d'envois mais je vois pas mon erreur une petite aide serait la bienvenue.

<? session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tchat - <?PHP echo $_GET['pseudo_chat'] ; ?> </title>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<div id="wrapper">
    <div id="menu">
        <p class="welcome">Welcome, <b><?php echo $_GET['pseudo_chat']; ?></b></p>
        <p class="logout"><a id="exit" href="#">Exit Chat</a></p>
        <div style="clear:both"></div>
    </div>    
    <div id="chatbox">
    <div class="refresh">
    
    </div>
    </div>
    
    <form name="connexion_chat" id="connexion_chat" action="" onSubmit="return false">
        <input name="usermsg" type="hidden" id="usermsg" value="<?php echo $_GET['pseudo_chat']; ?>" size="63" />
        <textarea name="message" id="message" style="width:80%;">Enter your message here</textarea>
        <input name="submit" type="submit" value="Send" id="johnlei"  />
    </form>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
    $('#message').click(function() {
        document.newMessage.textb.value = "";
    });
    
    $('#johnlei').click(function(){
        var username = $('#usermsg').val();
        var message = $('#message').val();
        
        
        if (message == "" || message == "Enter your message here") {
            return false;
        }
        
        var dataString = 'username=' + username + '&message=' + message;
        
        $.ajax({
            type: "POST",
            url: "Post_chat.php",
            data: dataString,
            success: function() {
                document.newMessage.textb.value = "";
            }
        });
    });
});

///////////////////////////////////////////////////////////////////////////////////////
$.ajaxSetup ({
    cache: false    //use for i.e browser to clean cache
});
$(setInterval(function(){
    $('.refresh').load('tchat_lu.php'); //this means that the items loaded by display.php will be prompted into the class refresh 
    $('.refresh').attr({ scrollTop: $('.refresh').attr('scrollHeight') }) //if the messages overflowed this line tells the textarea to focus the latest message    
}, 3000));
</script>
</body>
</html>