Hola.
estoy intentando hacer un sistema para dejar comentarios con ajax... pero no me sale... Sí que se ve el loading y el .gif de que esta cargandose.. pero luego no aparece el mensaje...
Código PHP:
//añadir comentario...
$(".sendc").click(function(){
var boxval=$("#content").val();
var dataString='content='+boxval;
if (boxval==''){
alert("please enter some text!");
}else{
$("#flashcomment").show();
$("#flashcomment").fadeIn(400);
$.ajax({
type:"POST",
url:"http://localhost/sendcomment.php",
data:dataString,
cache:false,
success:function(html){
$("#flashcomment").hide();
$("o1#update")=prepend(html);
$("o1#update li:first").slideDown("slow");
document.getElementById('content').value='';
document.getElementById('content').focus();
}
});
} return false;
});
sendcomment.php:
Código PHP:
<?php
$link=mysql_connect("localhost","***","***");
mysql_select_db("***",$link);
if(isset($_POST['content'])) {
$content=$_POST['content'];
$mess= "INSERT INTO messages (msg)"."VALUES('$content')";
$insert=mysql_query($mess);
$sql_in=mysql_query("SELECT msg,msg_id FROM messages order by msg_id desc");
$row=mysql_fetch_array($sql_in);
$msg=$row['msg'];
$msg_id=$row['msg_id'];
}
?>
<li class="bar<?php echo $msg_id; ?>">
<div align="left">
<?php echo &msg ?>
<a href="#" id="<?php echo $msg_id; ?>" class="deletemsg">X</a>
</div>
</li>
css:
Código HTML:
#flashcomment{
display:none;
}
#content{
width:270px;
margin-right:10px;
}
.loading{
font-size:16px;
}
ol.timeline{
list-style:none;font-size:1.2em;
}
ol.timeline li{
display:none;position:relative;
padding:.7em 0 .6em 0;
border-bottom:1px dashed #000;
line-height:1.1em;
background-color:#D3E7F5;
height:55px;
width:499px;}
ol.timeline li:first-child{
border-top:1px dashed #000;}