Jquery plugin Combogrid doesn't work
<p>I have a search box on my website where a registered user can be searched by name,email,city,state or country. I tried to implement auto suggestion functionality on that search box using Jquery's Combogrid plugin here: <a href="http://combogrid.justmybit.com/" rel="nofollow">http://combogrid.justmybit.com/</a> . I've tried very hard to get it working properly but no matter what It never seems to work. </p>

<p>I have a php file 'server.php' that sends data in JSON format which is used by this plugin to render auto suggestion grid containing data in tabular form. I copied the JSON output from Server.php file and put it in a text file. The plugin works fine when I set the resource file's URL to this text file, but fails to work when I set it to that PHP file. I know I'm missing something and need your help to patch that up.</p>

<p><strong>Here's my Combogrid's configuration</strong>
</p>

<pre><code>&lt;script&gt;
jQuery(document).ready(function(){
$('#switcher').themeswitcher({
    loadTheme:"Smoothness"
});
    $( "#project" ).combogrid({
    url: 'http://localhost/combogrid-1.6.2/server.php',

sord: "asc",    
debug:true,
sidx: "id",
rememberDrag: true,
rows: 10,
alternate: true,
replaceNull: true,
    colModel: [{'columnName':'name','width':'25','label':'Name'}, {'columnName':'country','width':'25','label':'Country'},{'columnName':'state','width':'25','label':'State'}, {'columnName':'city','width':'25','label':'City'}],
    select: function( event, ui ) {
        $( "#project" ).val( ui.item.name );

        document.location.href=ui.item.link;

        return false;
    }
});
</code></pre>

<p>});
</p>

<p><strong>SERVER.PHP</strong></p>

<pre class="lang-php prettyprint-override"><code>&lt;?php
$page = $_GET['page']; 
// get the requested page

$limit = $_GET['rows']; 
// get how many rows we want to have into the grid

$sidx = $_GET['sidx']; 
// get index row - i.e. user click to sort

$sord = $_GET['sord'];

$searchTerm = $_GET['searchTerm'];

// get thedirection

if(!$sidx) $sidx =1;

if ($searchTerm=="") {
$searchTerm="%"; 
} 
else 
{
$searchTerm = "%" . $searchTerm . "%";
}


$dbhost = "localhost";
$dbuser = "root";

$dbpassword = "";
$database = "userinfo";


// connect to the database

$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " .   mysql_error());


mysql_select_db($database) or die("Error conecting to db.");

$result = mysql_query("SELECT COUNT(*) AS count FROM userdata WHERE first like '$searchTerm'");

$row = mysql_fetch_array($result,MYSQL_ASSOC);

$count = $row['count'];

if( $count &gt;0 ) {

$total_pages = ceil($count/$limit);
}
else {
$total_pages = 0;
}

if ($page &gt; $total_pages) 
$page=$total_pages;

$start = $limit*$page - $limit;
// do not put $limit*($page - 1)

if($total_pages!=0) $SQL = "SELECT * FROM userdata WHERE first like '$searchTerm'  ORDER BY $sidx $sord LIMIT $start , $limit";
else $SQL = "SELECT * FROM userdata WHERE first like '$searchTerm'  ORDER BY $sidx $sord";

$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());


$response-&gt;page = $page;

$response-&gt;total = $total_pages;

$response-&gt;records = $count;

$i=0;

while($row = mysql_fetch_array($result,MYSQL_ASSOC)) 
{$response-&gt;rows[$i]['name']=$row['first'];

$response-&gt;rows[$i] ['cell']=array($row['first'],$row['country'],$row['state'],$row['city']);


$response-&gt;rows[$i]['name']=$row['first'];

$response-&gt;rows[$i]['country']=$row['country'];

$response-&gt;rows[$i]['state']=$row['state'];

$response-&gt;rows[$i]['city']=$row['city'];    
 $response-&gt;rows[$i]=array("name"=&gt;$row["first"],"country"=&gt;$row['country'],"state"=&gt;$row['state'],"city"=&gt;$row['city']);  $i++;
}        
  echo json_encode($response);

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
//$stringData = "{$_GET['page']} {$_GET['rows']} {$_GET['sidx'] } {$_GET['sord']}   {$_GET['searchTerm']}";
$stringData =$SQL." ".json_encode($response);
fwrite($fh, $stringData);
?&gt;
</code></pre>
