This project is read-only.

calling remote a script results.php?id

Jun 14, 2010 at 11:59 AM

I've evaluated many jquery autocomplete plugins yours seems to be complete but
perhaps I've no understood well how make this (I'm a newbye in jquery ):
 I'm not able to find an example about
how to call remote script passing the starting characters of the input field

All samples show how to query all data from a database

I have a big quantity of data to retrieve
and I would be able to filter them by the sql statement before returning them to the html page
I would be able to fire out my request to "result.php" after 3 char of input for example "1mg"

I would able to make somethig like this

<script type="text/javascript">  
    $().ready(function() {  
        $('#fb').flexbox('result.php?id='+content_of_input  ,
        {
        displayValue:'codice',
        width : 400,

minChars : 3,

....

... and so on...
        }
        );
    }); 

The content of "result.php" is like this:

<?php

// WITH ADODB
          $db_gx = NewADOConnection($TIPODB);
           $db_gx ->Connect($HOST,$DBUSER,$DBPASS,$DBDATA);
 
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$db_gx->debug=false;

if(isset($_GET))
{
  $codice=$_GET['id'] ;
 
}
elseif ( isset($_POST['id']) )
{
$codice=$_POST['id'];
}
else
{
$codice="1mgat"; // to limit query
}

$sql="SELECT a_sigla_art as codice , a_descr_art as descrizione FROM art  WHERE a_sigla_art LIKE '".$codice."%' ORDER BY a_sigla_art ";
$rs=$db_gx->Execute($sql);
$righe=$rs->GetArray();
$result=array();
$output="{\"results\":[\n";
$i=1;

foreach($righe as $value)
{
$output.="{\"id\":$i,\"codice\":\"".trim($value[0])."\",\"descrizione\":\"".trim($value[1])."\"},\n";
}
$output.="]}\n";
print $output;
?>

 

Thank

Jun 14, 2010 at 2:14 PM

Sorry I've found that when the script is call this

parameters are send via GET or POST setting "method : string (default = 'GET')"

infact debuging the script I've found that are send this

GET VARIABLE - Value

q-5bk
p-1
s-10
contentType-application/json; charset=utf-8

I don't know what is p and s but now i've modified php script like this

if(isset($_GET['q']))
{
  $codice=$_GET['q'] ;
 
}

and so on