you are assigning the html here to what's in data.
to access i think is data = $("example").text;
try this but breakpoint it in firebug, because in not using firefox right now.
Date: Wed, 11 Mar 2009 15:18:10 +0000
Subject: [jQuery] Re: AutoComplete
From: [email protected]
To: [email protected]
Do i access "data" like this;
$("example").html(data);
On Wed, Mar 11, 2009 at 3:11 PM, Joseph Le Brech <[email protected]> wrote:
you should be sanitising your sql aswell.
> Date: Wed, 11 Mar 2009 08:00:23 -0700
> Subject: [jQuery] Re: AutoComplete
> From: [email protected]
> To: [email protected]
>
>
> What is the purpose of the ".get()" ?
>
> The autocomplete plugin already has the ajax call all wired into it,
> there's no need to do that on your own
>
> $(document).ready(function(){
> $("#example").autocomplete(
> "test.php"
> ).result(function(a,data,c) {
> // variable "data" has the value the user selected
> });
> });
>
>
>
> On Mar 11, 10:45 am, Bright Dadson <[email protected]>
> wrote:
> > Hi Experts,
> >
> > I am trying to use jQuery get function to develop an autocomplete which will
> > display suggestion as soon as users starts typing like this;
> >
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd">
> > <html>
> > <head>
> > <script src="http://code.jquery.com/jquery-latest.js"></script>
> > <link rel="stylesheet"
> > href="http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/main.css"
> > type="text/css" />
> > <link rel="stylesheet"
> > href="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp..."
> > type="text/css" />
> > <script type="text/javascript"
> > src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.bgif...
> > "></script>
> > <script type="text/javascript"
> > src="http://dev.jquery.com/view/trunk/plugins/autocomplete/lib/jquery.dime...
> > "></script>
> > <script type="text/javascript"
> > src="http://dev.jquery.com/view/trunk/plugins/autocomplete/jquery.autocomp...
> > "></script>
> > <script>
> > $(document).ready(function(){
> > var result = $.get("test.php", { data:
> > "q"+$("#example").attr('value') },
> > function(data){
> > $("#example").html(data);
> > });
> >
> > $("#example").autocomplete(result);
> > });
> > </script>
> >
> > </head>
> > <body>
> > Company name: <input id="example" />
> > </body>
> > </html>
> >
> > and my backend php script looks like this;
> >
> > <?php
> > $q=$_GET["q"];
> > $con = mysql_connect('host', 'user', 'password');
> > if (!$con)
> > {
> > die('Could not connect: ' . mysql_error());
> > }
> >
> > mysql_select_db("database", $con);
> >
> > $sql="SELECT company_name FROM company WHERE company_name =
> > '".$q."'";
> >
> > $result = mysql_query($sql);
> >
> > while($row = mysql_fetch_array($result))
> > {
> > echo $row['company_name'];
> > }
> >
> > mysql_close($con);
> > ?>
> >
> > Unfurtunately tthis donot work as required - i donot see any suggestion. Do
> > anyone know what i am doing wrong here?
> >
> > Pls help.
Windows Live Hotmail just got better. Find out more!
_________________________________________________________________
View your Twitter and Flickr updates from one place – Learn more!
http://clk.atdmt.com/UKM/go/137984870/direct/01/