Double Posting in Internet Explorer
For some reason, my chat program seems to double post in Internet Explorer but not in Firefox or Chrome
-
function Get_Message() {
if(!locked){
$.ajax({
type: "GET",
url: "action/getmessages.php",
beforeSend: function(){
// Handle the beforeSend event
locked = true;
},
success: function(data){
if(data != '') {
$("ul.shoutbox li:first").before(data);
$('ul.shoutbox li:even').css('background-color','#333333');
$('ul.shoutbox li:odd').css('background-color','#444444');
PlaySound();
}
locked = false;
}
});
}
}
This is the PHP i am using
-
<?php
// Display errors.
//ini_set("display_errors", "On");
// Set reporting level.
//error_reporting(E_ALL|E_STRICT);
// Require DB connection.
require_once("db_class.php");
// Start sessions.
session_start();
include_once "init.inc.php";
require_once 'HTML/BBCodeParser.php';
$parser = new HTML_BBCodeParser(parse_ini_file('BBCodeParser.ini'));
// New DB class.
$db = new DB("localhost", "shoutbox", "root", "");
$pos = 0;
$pos = $_SESSION['position'];
if($pos > 0){
$db->query("SELECT * FROM posts WHERE id > :pos ORDER BY id DESC", array("pos"=> $pos));
} else {
$db->query("SELECT * FROM posts ORDER BY id DESC LIMIT 5");
}
$newPos = $pos;
while($data = $db->getAssocRow()){
if($data["id"] > $newPos) {$newPos = $data["id"];}
$body = $data['data'];
$body = str_replace(':)','<img src="img/smilies/485.png" width="15px" height="15px" class="icon">',$body);
$body = str_replace(':D','<img src="img/smilies/486.png" width="15px" height="15px" class="icon">',$body);
$body = str_replace(':(','<img src="img/smilies/363.png" width="15px" height="15px" class="icon">',$body);
$body = str_replace(':S','<img src="img/smilies/286.gif" width="15px" height="15px" class="icon">',$body);
echo "<li><h2>".$data['alias_name'].": </h2><p>".$parser->qParse($body)."</p></li>";
}
$_SESSION['position'] = $newPos;
if($db->getLastError()){
print_r($db->getLastError());
}
?>