TeddyKiller Posted June 14, 2010 Share Posted June 14, 2010 I have a wall post thing, and.. well you comment on it, but.. when i submit a post, it brings down the 'loading comment' and it disappears - as it should do. But the php script doesn't execute, it doesn't even add it to the database.. I cant think of where the problem is. Ajax/javacript $(function() { //Update Message... $(".post").click(function() { var boxval = $("#message").val(); if(boxval=='') { alert("Please Enter Some Text"); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<span class="loading">Loading Comment...</span>'); $.ajax({ type: "POST", url: "update_wall.php", data: {upd: "2", content: boxval}, cache: false, success: function(html){ $("div#update").prepend(html); $("div#update").slideDown("slow"); document.getElementById('content').value=''; document.getElementById('content').focus(); $("#flash").hide(); } }); } return false; }); }); PHP <?php require_once("include/config.php"); if(!$session->logged_in) : redirect("/index.php"); endif; if($_POST['upd'] == '1') { if(isset($_POST['content'])) { $content = clean($_POST['content'],1,0,0); $time = time(); $query = $db->execute("INSERT INTO horblewall (user_id, comment, posted) VALUES ('$user->id', '$content', '$time')"); $query = $db->execute("SELECT w.*, u.avatar, u.displayname FROM horblewall as w, users as u WHERE u.id = w.user_id ORDER BY w.posted DESC"); $row = $db->fetchassoc($query); echo '<div style="border-bottom:1px solid #e11919;" class="bar'.$row['id'].'"> <div style="text-align:left; min-height:90px;"> <div style="float:right; width:105px;"> Posted on<br />'.date("d.m.y H:i", $row['posted']).' <br /><br /> Msg no. '.$row['id'].' <br />'; if($user->level == '9') { echo '<br /> <span class="delete_button"><a href="#" id="'.$row['id'].'" class="delete_update">Delete</a></span>'; } else if($row['user_id'] == $user->id) { echo '<br /> <span class="delete_button"><a href="#" id="'.$row['id'].'" class="delete_update">Delete</a></span>'; } echo '</div> <div style="float:left; width:80px; text-align:center;"> <img src="resize_image.php?file='.$row['avatar'].'&size=70" /> <br /> <a href="#">'.$row['displayname'].'</a> </div> <div style="margin-right:120px; margin-left:95px;"><p>'.$row['comment'].'</p></div> </div> </div>'; } else { echo 'Message empty'; } } ?> Wheres the problem? I've removed the redirection from the php, and.. well, same thing happens =[ Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted June 14, 2010 Share Posted June 14, 2010 Tried running it with Firebug, checking the console to see if the Ajax call is running correctly? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.