I am working on a Help Desk Ticketing system and have a page called MY TICKETS which shows all tickets in grids. the problem is that the number of records are around 30 to 40 but there is a lag around more then 10 seconds while populating the grid. I think its the way I've written. So I need suggestion to improve or correct my problems if any. Please help..here is the code
Code: function defaultgrid() { var dataString = "mycusid="+document.getElementById('mycusid').value+"&dtype="+document.getElementById('vtype').value+"&sid="+Math.random(); $.ajax({ type: "GET", //GET Method used instead of POST url: "buildgrid.php", //php file that processes the data data: dataString, //Pass the data cache: false, //Do not cache the page success: function(returnString) { document.getElementById('grid_data').innerHTML = returnString; } }); }
Finally the code which actually populates the grid... --------------------- buildgrid.php ---------------------
Code: <?php require_once('hostinfo.php');
// Connect to server and select databse. $connection = mysql_connect($dbhost, $dbuser, $dbpass) or die("Error : Cannot connect to the database.."); mysql_select_db($dbname) or die("Error : Cannot select Database...");
//Display type $vtype = $_GET['dtype']; $pcusid = $_GET['mycusid'];
if($vtype == 'G') { //Default query $squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' order by ticketdate desc"; }
if($vtype == 'O') { //Default query $squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' AND status='O' order by ticketdate desc"; }
if($vtype == 'C') { //Default query $squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' AND status='C' order by ticketdate desc"; }
if($vtype == 'D') { //Default query $squery = "SELECT ticketno, c_id, city, department, subject, priority, status, ticketdate, messagebody from ticketmaster where c_id = '$pcusid' and department='S' order by ticketdate desc"; } //Execute Statement using mySQL database $result = mysql_query($squery, $connection) or die(mysql_error()); $ticketRS = mysql_fetch_assoc($result);